Estou enviando a requisição abaixo:
LRESTClient : TRESTClient;
LRESTRequest : TRESTRequest;
LRESTResponse: TRESTResponse;
body:String;
begin
LRESTClient := TRESTClient.Create('https://api.nuvemshop.com.br/v1/2905426/products/164095220/variants/619424940');
try
LRESTClient.SynchronizedEvents := False;
LRESTResponse := TRESTResponse.Create(LRESTClient);
try
LRESTRequest := TRESTRequest.Create(LRESTClient);
try
LRESTRequest.Client := LRESTClient;
LRESTClient.ContentType := 'application/json';
LRESTClient.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
LRESTRequest.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
LRESTRequest.AcceptCharset := 'UTF-8, *;q=0.8';
LRestClient.AcceptCharset := 'UTF-8, *;q=0.8';
LRESTRequest.AddParameter('Authentication','bearer xxxxxxxx',pkHTTPHEADER, [poDoNotEncode]);
LRESTRequest.AddParameter('User-Agent','Your App Name (xxxxxxxxxx)',pkHTTPHEADER, [poDoNotEncode]);
body := '{'+
' "id": 619424940,'+
' "price": "38.00",'+
' "product_id": 164095220,'+
' "stock": 5'+
'}';
LRESTRequest.AddParameter('body',body,pkREQUESTBODY, [poDoNotEncode]);
LRESTRequest.Response := LRESTResponse;
LRESTRequest.SynchronizedEvents := False;
LRestRequest.Method := rmPut;
LRESTResponse.ContentType := 'application/json';
LRESTRequest.Execute;
cxMemo1.lines.text := LRESTResponse.Content;
finally
LRESTRequest.free;
end;
finally
LRESTResponse.free;
end;
finally
LRESTClient.free;
end;
porem está retornando:
{
"code": 415,
"message": "Unsupported Media Type",
"description": "Content-Type should be application\/json"
}