Problem Setting Object Relationships with REST API

Mission: RELATIONS MASTER
Task: Set Object Relationships with API

I am having problem completing 2/5 task using the following Curl command:

curl -H Content-Type:application/json
-X POST
-d [ {objectId:“BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF”, {objectId:“3800”} ]
-v https://api.backendless.com/39C8B0AF-2F6E-7F6A-FF0C-1E1B176ED600/CC6B9318-476B-4DB2-8CEF-4C21CD4AA681/data/Person/BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF/cityofResidence

note: objectID as defined under “-d” are parentObjectID (i.e. “Joe” in Person table) and relationObjectID (i.e. “Dallas” in City table)

I followed the syntax given on the documentation but seems like I am not getting it right as shown in the error message below :

{“code”:8002,“message”:“Could not parse request with message: Error decoding json body: com.fasterxml.jackson.core.JsonParseException: Unexpected character (‘o’ (code 111)): was expecting double-quote to start field name\n at [Source: (akka.util.ByteIterator$ByteArrayIterator$$anon$1); line: 1, column: 4], status code 400, headers POST /39C8B0AF-2F6E-7F6A-FF0C-1E1B176ED600/CC6B9318-476B-4DB2-8CEF-4C21CD4AA681/data/Person/BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF/cityofResidence”,“errorData”:{}}* Connection #0 to host api.backendless.com left intact*

Appreciate any help and advice please.

Leon

Hi @Leon_Lim,

you’re sending wrong JSON payload. Try this one:

curl -H Content-Type:application/json
-X POST
-d [ {"objectId":"3800"} ]
-v https://api.backendless.com/39C8B0AF-2F6E-7F6A-FF0C-1E1B176ED600/CC6B9318-476B-4DB2-8CEF-4C21CD4AA681/data/Person/BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF/cityofResidence

Regards,
Stanislaw

Thanks @stanislaw.grin for the help and advice.
I have followed the JSON payload as advised but I am still getting the error message as below:

{“code”:8002,“message”:“Could not parse request with message: Error decoding json body: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (akka.util.ByteIterator$ByteArrayIterator$$anon$1); line: 1, column: 1])\n at [Source: (akka.util.ByteIterator$ByteArrayIterator$$anon$1); line: 1, column: 2], status code 400, headers POST /39C8B0AF-2F6E-7F6A-FF0C-1E1B176ED600/CC6B9318-476B-4DB2-8CEF-4C21CD4AA681/data/Person/BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF/cityofResidence”,“errorData”:{}}* Connection #0 to host api.backendless.com left intact

I am new to coding and appreciate your thoughts or advice please.

thanks again for your help.
Leon

Sorry, here is the correct one:

curl 'https://api.backendless.com/39C8B0AF-2F6E-7F6A-FF0C-1E1B176ED600/CC6B9318-476B-4DB2-8CEF-4C21CD4AA681/data/Person/BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF/cityofResidence' \
-H 'Content-Type: application/json' \
-d '["3800"]'

Please let me know if it works for you.

Regards,
Stanislaw

Thanks @stanislaw.grin and yes it works but I need to remove all single quotes as below else I am getting syntax error messages.

curl https://api.backendless.com/39C8B0AF-2F6E-7F6A-FF0C-1E1B176ED600/CC6B9318-476B4DB2-8CEF-4C21CD4AA681/data/Person/BC63E5BE-4E38-48B5-ACAD-23EDF9544BDF/cityofResidence
-H Content-Type:application/json
-d [“3800”]

Thanks again and regards,
Leon