Hello I try to use the urlread2 function within matlab to send a request to a REST API. In general this does work already, but for one specific API call there is a documented bug in the API: Normally I would use HTTP method "DELETE" and pass the request, like here:
headers = [http_createHeader('Content-Type','application/json; charset=UTF-8'),...
http_createHeader('Accept','application/json; charset=UTF-8'),...
http_createHeader('X-IG-API-KEY',api_key)];
json_body = savejson('',body);
response = urlread2(myURL,'DELETE',json_body,headers);
This results in an error. Instead I am advised to use:
headers = [http_createHeader('Content-Type','application/json; charset=UTF-8'),...
http_createHeader('Accept','application/json; charset=UTF-8'),...
http_createHeader('X-IG-API-KEY',api_key,...
http_createHeader('_method','DELETE')];
json_body = savejson('',body);
response = urlread2(myURL,'POST',json_body,headers);
The reason for the bug is said to be that otherwise, for unknown reason, the message body gets lost during the process and that yields the error.
My problem is now that this workaround does work in the sandbox (no matlab code!). But using matlab as shown here doesn't change anything, same response in both cases. So I guess that the urlread2 function may not process the request as expected. Does anybody have an idea here?
The both dependencies here are wellknown matlab funcs: