I'm facing an issue for a week ...creating an entity for an assistant from my company website via curl. Every time I send a request with an array inside the PHP it throws the error. The main error is 'Invalid request body' the reason is when I pass the synonyms it says "synonyms should be of type Array". My array which I pass is..........here
(3) ["wer", "were", "rrr"]
0: "wer"
1: "were"
2: "rrr"
length: 3
__proto__: Array(0)
and the code where I pass the values are
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"entity\": \"" . $intentname . "\",\"fuzzy_match\": true,\"values\":[{\"value\":\"" . $value . "\",\"type\":\"" . $type . "\",\"synonyms\":\"" . $array . "\"}]}");
curl_setopt($ch, CURLOPT_USERPWD, 'apikey' . ':' . '' . $apikey . '');
but when I try to convert it to JSON it trows something like the error is JSON position...
The common error is
error: "Invalid Request Body", errors: Array(1), code: 400}
code: 400
error: "Invalid Request Body"
errors: [{…}]
__proto__: Object
I have tried to change it several arrays through PHP and js but the issue doesn't resolve. Tried many StackOverflow questions none of them resolves the issue.
Thank you.