-2

I have tried to update an item following the Directus documentation, but I can't update the record, it always returns

{ "error" : { "code" : 6, "message" : "Method Not Allowed" } }

My PHP code is:

$url = 'https://cms.domain.com/public/name-of-project/items/products/1?access_token=TOKEN';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['category'=>43]));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);

What am I doing wrong?

Ivan86
  • 5,695
  • 2
  • 14
  • 30

1 Answers1

1

I don't know if you already solved the issue but you need to set the method to POST:

curl_setopt($ch, CURLOPT_POST, 1);

Otherwise a GET request is made, which seems not to be supported.

jumper85
  • 472
  • 3
  • 9