It is a good example of using cUrl command on back4app by httpJob!
https://dashboard.back4app.com/apidocs?shell#reading-objects provided:
[CODE title="curl"]curl -X GET \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-G \
--data-urlencode "where={\"myCustomKey1Name\":\"myCustomKey1Value\"}" \
https://parseapi.back4app.com/classes/MyCustomClassName [/CODE]
https://dashboard.back4app.com/apidocs?shell#creating-objects provided:
[CODE title="curl"]curl -X POST \
-H "X-Parse-Application-Id: BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f" \
-H "X-Parse-REST-API-Key: swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w" \
-H "Content-Type: application/json" \
-d '{"myCustomKey1Name":"myCustomKey1Value","myCustomKey2Name":"myCustomKey2Value"}' \
https://parseapi.back4app.com/classes/MyCustomClassName[/CODE]
I translate these curl commands into B4A codes:
[CODE lang="b4x" title="b4a"]Sub sendBack4AppRequest()
Dim Job As HttpJob
Job.initialize("request", Me)
Job.Download($"https://parseapi.back4app.com/classes/B4aVehicle?where={"price": {"${Chr(36)}gt":5000} }"$)
Job.GetRequest.SetHeader("X-Parse-Application-Id", "BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f")
Job.GetRequest.SetHeader("X-Parse-REST-API-Key", "swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w")
End Sub
Sub postdataBack4App(i_name As String, i_prc As Int, i_color As String)
If i_name = "" Then i_name = "Window"
If i_prc = 0 Then i_prc = 10000
If i_color = "" Then i_color = "Blue"
'strdata = $"{"name":"${i_name}","price":${i_prc},"color":"${i_color}"}"$
Dim strdata As String = map2JsonStr(CreateMap("name": i_name, "price": i_prc, "color": i_color))
Log("strdata: " & strdata)
Dim Job As HttpJob
Job.initialize("post", Me)
Job.PostString("https://parseapi.back4app.com/classes/B4aVehicle", strdata)
Job.GetRequest.SetHeader("X-Parse-Application-Id", "BCrUQVkk80pCdeImSXoKXL5ZCtyyEZwbN7mAb11f")
Job.GetRequest.SetHeader("X-Parse-REST-API-Key", "swrFFIXJlFudtF3HkZPtfybDFRTmS7sPwvGUzQ9w")
Job.GetRequest.SetContentType("application/json")
ProgressDialogShow("Saving...")
End Sub
Sub JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
If j.JobName = "request" Then
Try
Dim jparser As JSONParser
jparser.Initialize(j.GetString)
Dim map1 As Map = jparser.Nextobject
Dim lst1 As List = map1.Get("results")
ListView1.Clear
fillTheList(lst1)
Catch
Log(LastException)
End Try
End If
If j.JobName = "post" Then
Try
Dim jparser As JSONParser
jparser.Initialize(j.GetString)
Dim map2 As Map = jparser.NextObject
Msgbox2Async($"objectId: ${map2.Get("objectId")}${CRLF}createdAt: ${map2.Get("createdAt")}"$, "Response","Done","","",Null, True)
sendBack4AppRequest
Catch
Log(LastException)
End Try
End If
End If
j.Release
End Sub[/CODE]