I'm trying to make a POST request using TCustomRESTRequest, to add more specific headers needed by the API I'm trying to reach.
As I'm adding headers to my request, I tried to add the specified Content-Type: multipart/form-data:
var
RESTRequest : TCustomRESTRequest;
RESTClient : TRESTClient;
Response : TCustomRESTResponse;
begin
RESTRequest := TCustomRESTRequest.create(nil);
RESTClient := TRESTClient.create('');
try
RESTClient.BaseURL := 'urltoreach';
RESTRequest.Client := RESTClient;
RESTRequest.AddParameter('Content-Type','multipart/form-data',pkHTTPHEADER,poDoNotEncode);
RESTRequest.Method := rmPOST;
RESTRequest.Execute;
Response := RESTRequest.Response;
if Response.Status.Success then
begin
showmessage('success');
end;
else
begin
showmessage(Response.StatusText + ' : ' + Response.Content);
end;
finally
RESTRequest.free;
RESTClient.free;
end;
end;
The problem I have is that I'm getting an error message:
'Unsupported media type : {"errors":"unsupported media type multipart%2Fform-data"}'
Meaning that my / is getting encoded even though I'm requesting poDoNotEncode as a parameter option.
Do you have any idea why?