delete relationship using rest

HI
We are trying to update the category values based on the user profile from the table “Subcategory” using the following code, but when we tried to delete the relation between parent and child table (Retailer) to update, it’s not getting updated:

$pest = new PestJson(API_URL);
$headers = array(“application-id” => APLICATION_ID,“secret-key” => SECERET_KEY);

$dataValue = array("__meta" => array(“Retailer” => array(“objectId” =>“B6CCA48D-8BBF-9F6A-FFA4-4B7520A10600”,"___class" => “Retailer”),"___class" => “Retailer”));
$api_result = $pest->put(SUBCATEGORY."/52112D89-DAD5-381C-FF99-C55BF1552900",$dataValue, $headers);
$result = $api_result;Please let me know what I am doing wrong.

Hi Sanjeev,

Could you please show what the actual HTTP request (with headers and body) looks like?

Regards,
Mark

Additional information:
The subcategory table holds the information of retailers who are belongs to that sub-category so our requirement is to update the retailer profile based on their sub-category selection.

Parent table: Subcategory
relation table: retailer

I want to remove the relationship between Retailer to Subcategory. Please suggest me

Code here:

<?php $url = 'https://api.backendless.com/v1/data/Subcategory/52112D89-DAD5-381C-FF99-C55BF1552900'; $data_string = '{ "__meta": "owner:52112D89-DAD5-381C-FF99-C55BF1552900;retailer:B6CCA48D-8BBF-9F6A-FFA4-4B7520A10600"}'; $headers = array( 'Content-Type : application/json', 'application-id : C622D5EA-C718-17C3-FFCC-20CF403E3900', 'secret-key : XXXXXXXXXXXXXXXXXXXXXXXX ); // Open connection $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute request $result = curl_exec($ch); // Close connection curl_close($ch); print_r(json_decode($result, true)); ?>

Sorry, I do not understand what your code does. The second snippet of code is rather different than the first. What I need from you (so I can help you) is an HTTP request with the following:

    HTTP command (GET, PUT, POST, DELETE, etc) URL HTTP headers HTTP body
Regards, Mark

Hi Mark,

I want to code for delete the relationship using rest. Can you give me some reference code for delete the relation between two data table with explain all variable.

Thanking you for support

Hi, Sanjeev,

Here you go: http://backendless.com/documentation/data/rest/data_relations_delete.htm
Regards,
Sergey

Hi ,

Can we schedule the gotomeeting, as this is very urgent and we need to make the site live today.
Please reply your phone number for call today.

Thanks

Sanjeev, if you could just follow the documentation, it has a super clear example showing exactly what needs to be done.

Mark

Hi Mark,

I have easily add relation between two table according to document but i am not able to remove the relation between two table according to this document http://backendless.com/documentation/data/rest/data_relations_delete.htm.

Please help me it’s urgent for me Thanks

We have been asking you all along to show what request you are sending. This is the most critical piece of information for us to know what you’re doing wrong. Please share the following:

    HTTP command (GET, PUT, POST, DELETE, etc) URL HTTP headers HTTP body

Here’s the
details:

Http
command - PUT

Url - https://api.backendless.com/v1/data/Subcategory/87CB199E-9FA8-B33F-FF80-74E5245C6500

  1.   Header   - 
    

{
“application-id”: C622D5EA-C718-17C3-FFCC-20CF403E3900

             "secret-key”:

XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX }

  1.   Http body:
    

{"__meta" :
“retailer:B6CCA48D-8BBF-9F6A-FFA4-4B7520A10600”,“retailer”:“objectId:B6CCA48D-8BBF-9F6A-FFA4-4B7520A10600”}

      Response:

{

“retailer”:
“objectId:B6CCA48D-8BBF-9F6A-FFA4-4B7520A10600”,

“created”: 1427414400000,

“___class”:
“Subcategory”,

“ownerId”: null,

“subcategory”:
“Formal”,

“updated”: 1439541567000,

“objectId”:
“87CB199E-9FA8-B33F-FF80-74E5245C6500”,

“__meta”: “{“relationRemovalIds”:{},“selectedProperties”:[“retailer”,“created”,”___class",“ownerId”,“subcategory”,“updated”,“objectId”,"__meta"],“relatedObjects”:{}}"

}

Problem:

Retailer relation objects not deleting from Subcategory.

Sanjeev,

I recorded a video just for you, using your use-case. In the video you will see the process for getting the REST request body for removing a relation:
[video]https://youtu.be/KKOZcD9laIA[/video]

Regards,
Mark

Hi Mark,

Thanks for this video… Now this problem has been solved.
Thanks for this support