I've been trying to make a server side Swift program which downloads the JSON data from Parse using Parse's cURL call.
For this to work, I need to use a package for Swift called "Perfect cURL" which works on server side swift.
I am unable to translate one of the queries to work with Perfect cURL. What I have been able to do at the moment is download a whole class of data from Parse using the call but can't send a condition.
The cURL I want to send looks like this in Parse
curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'where={"playerName":"Sean Plott","cheatMode":false}' \
https://api.parse.com/1/classes/GameScore
This is what I have been able to convert it to using Perfect cURL
let url = serverURL
let custom = CURLRequest.Header.Name.custom(name: "X-Parse-Application-Id")
let custom2 = CURLRequest.Header.Name.custom(name: "X-Parse-REST-API-Key")
let custom3 = CURLRequest.Header.Name.custom(name: "Content-Type")
let appIDS = "\(appID)"
let clientKeyS = "\(clientKey)"
let content = "application/json"
let request = CURLRequest(url, .addHeader(custom, appIDS),
.addHeader(custom2, clientKeyS),
.addHeader(custom3, content),
.httpMethod(.get))
What this generates is the whole class of JSON data, but I want to be able to add the condition
-G \
--data-urlencode 'where={"playerName":"Sean Plott","cheatMode":false}' \
Is anyone familiar with Perfect cURL or has any knowledge of how to go about doing this in swift?
Thanks in advance.
let serverURL = "https://api.parse.com/1/classes/GameScore"
let query = "where={\"playerName\":\"Sean Plott\",\"cheatMode\":false}"
let url = serverURL + "?" + query.stringByEncodingURL
you can join the Perfect slack channel to get an instant feedback.