Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi RestRequest with Post Var (https://www.delphipraxis.net/204120-restrequest-post-var.html)

Rabihan35 25. Apr 2020 18:15

RestRequest with Post Var
 
Hi everyone,

I have the following problem, I'm doing a restclient application which will send request to a Restserver API, i was able to connect and getthe responses of my requests,
now the problem is when I'm sending the request with Parameters, the server is ignoring them, or at least the filter parameters are ignored, the required information, which are timestamp, salt and signature are accepted but all others are ignored. as an example from the documentation of the Server's API i have the following php example:

// The GET vars
$GET_VARS = array(
"go" => "clips",
"do" => "list"
);

// The POST vars
$POST_VARS = array(
"fields" => "id,title", // Include only id, and title
"paging" => 1, // Allow paging
"resultsPerPageFilter" => 5, // Return 5 results per page
"current_page" => 1, // Return the page No. 1
"statusFilter" => "any", // Include Clips with any status
"sortByFilter" => "date", // Sort Clips by date (latest first)
"generateEmbedCode" => 1, // Generate embed code for each Clip
"embedWidth" => 400, // Set the Embed code Width = 400px
"embedHeight" => 225, // Set the Embed code Height = 225px
"embedURLVars" => "&autoplay=1" // Include the Video Player vars in the Embed code
);

form delphi I was able to send the get var in addition to the required information and the server response is ok, but I was not able sending the other variables (pos_var)


// get the signature
Signature := getSignature(TimeStamp, Salt);

RESTRequest1.AddParameter('go','clips');
RESTRequest1.AddParameter('do','list');
RESTRequest1.AddParameter('timestamp',TimeStamp);
RESTRequest1.AddParameter('salt',Salt);

RESTRequest1.AddParameter('key',KeyID);

RESTRequest1.AddParameter('signature',Signature); ----> till this point everything is OK

RESTRequest1.AddParameter('fields','title'); ------> this parameter is ignored same as all the others in the POST_VAR!!!!


ResponseMemo.Lines.Add('Request: '+RESTRequest1.GetFullRequestURL(True));
//using Methode = rmGet
RESTRequest1.Execute;
jValue:=RESTResponse1.JSONValue;
ResponseMemo.Text:= jValue.ToString;

I have no idea how to send the POST_VAR shown in the PHP example.

thanks for all the help I get

Uwe Raabe 26. Apr 2020 09:52

AW: RestRequest with Post Var
 
I am not familiar with PHP, but you can try this for all $POST_VARS parameter:
Delphi-Quellcode:
...
RESTRequest1.AddParameter('fields','title', TRESTRequestParameterKind.pkREQUESTBODY);
...

Rabihan35 26. Apr 2020 23:03

AW: RestRequest with Post Var
 
thanks for your reply, will try it and let you know.

Rabihan35 27. Apr 2020 00:04

AW: RestRequest with Post Var
 
I have no idea why but it still ignoring the parameters. would it work if i use indy instead?
thanks

Uwe Raabe 27. Apr 2020 07:45

AW: RestRequest with Post Var
 
It should work with both systems. Do you have a working PHP (or other) solution where you can intercept the request for an analysis?


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz