I am using Thunkable with Backendless and the REST API.
After successfully inserting a new record I am now trying Add a Relation to the Parent Object.
When I do the PUT request to Add the Relation as per the documentation: https://backendless.com/docs/rest/data_explicit_relation_list.html#example
I get the following error:
{“code”:1043,"message:“Could not parse request body. Please, specify Content-Type:application/json”,“errorData{}}”
There is no error 1043 in the documentation plus I am definitely setting up the Content type header properly as well.
The relationship is as follows:
I have a parent table called “Variety” and a child table called “Batch”.
In the parent table “Variety” I have setup a 1:N relationship (called “Batches”) to the “Batch” table.
After inserting a new “Batch” Record I get it’s objectId.
I already have the parent’s objectId as well
I then execute a PUT request to add the relationship using this type of URL: https://xxxx.backendless.app/api/data/<table-name>/<parentObjectId>/<relationName>
And then in the Body I put an array with the child “Batch” objectId (as required) and execute the PUT Request:
[“A164A49C-5F5E-431B-9B9D-A8CAE1DDFF21”]
and then I get the above error.
I have tried various formats in the body, and nothing works.
We need to make sure that the request is correct, so I ask you to run it using curl (you can do this in the terminal) or you can also do it in the REST Console:
Thanks Alexander
I’ve been through the code again and again and tried all sorts of things but I still get the same error.
So I’m stumped.
I’ve included a snippet of the Thunkable code and it looks like this, after I have Inserted the child item and got both objectId’s of Parent and Child. I use the Notes field and Message Alert in the UI to debug the body and response data in the meantime.
I put the Body data in, as-is. Do I need to convert it or modify it somehow first?
I think it must have something to do with how the body data is formatted or interpreted in the http call?
There is a “generate JSON from object” method which I have tried, when setting the body data as well and that also fails. Any ideas?
My bad!
I realise now that I was setting the header incorrectly.
I was putting in text that said: Content-Type: application/json.
Instead it should ACTUALLY be a Thunkable object, ie: