Hello, I'm trying to do a 'POST' in the WooCommerce Rest API using Delphi. I've done several tests using a lib. which I downloaded on link but without success. So, since there is now the 'RestClient' palette, I have tried with 'TRestClient', 'TRestRequest', 'TOAuth1Authenticator' and lastly I only inform the consumer_key and consumer_secret, but it passes the information [oauth_consumer_key, oauth_timestamp, oauth_nonce, oauth_signature, and oauth_signature_method] in the header, but must be passed as a query string.
The OAuth parameters must be added to the query string parameters and not included in the Authorization header. This is because there is no reliable cross-platform way to get the raw request headers in WordPress.
In the 'REST-Library :: Demos' demo, there is no example of the OAuth 1.0a (One Leg) stream. Anyway, I would like to know how to send the parameters as query string, using the components, or if there is another way to send this request to the API.
OAuth1Authenticator1.ConsumerKey := 'ck_f972e91046ea920e8b7c8141e1df516d7eea47b8';
OAuth1Authenticator1.ConsumerSecret := 'cs_adc97ab54caffe1c06b7f8dbb0c07de0adaa3f92';
OAuth1Authenticator1.SigningClassName := 'TOAuth1SignatureMethod_HMAC_SHA1';
OAuth1Authenticator1.CallbackEndpoint := '';
//oauth1.Authenticate(RESTRequest1);
RESTClient1.Authenticator := OAuth1Authenticator1;
RESTClient1.BaseURL := 'http://localhost/wordpress/wc-api/v2';
RESTRequest1.Resource := 'products';
RESTRequest1.Method := TRESTRequestMethod.rmPOST;
RESTRequest1.Params.AddItem('title', 'produto teste', TRESTRequestParameterKind.pkGETorPOST);
RESTRequest1.Execute;
if assigned(RESTResponse1.JSONValue) then
begin
Memo1.Lines.Text := TJson.Format(RESTResponse1.JSONValue)
end
else
begin
Memo1.Lines.Add(RESTResponse1.Content);
end;