Welcome! Log In Create A New Profile

Advanced

Curl to WinDEV

Posted by SteveSitas 
Curl to WinDEV
September 05, 2020 10:32AM
Hi,

what would be the OPTIMAL way to translate the following curl lines to WINDEV 25?


----------------------------------------------------------------------------

curl -v -X POST "[mydata-dev.azure-api.net];
-H "aade-user-id: {aade-user-id}"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}"

-----------------------------------------------------------------------------

the first line is the "address: of the RestAPI
the 2nd and 3rd line are the username and the password
the 4th line is the actual data to be POSTed (XML structure - comes from an XSD)

Regards
Steven Sitas
www.alpha360.biz
Re: Curl to WinDEV
September 07, 2020 04:56PM
Hi:
Try this:
myRequest is httpRequest;
myRequest..URL = "mydata-dev.azure-api.net";
myRequest..Method = httpPost;
myRequest..Header["aade-user-id"] = "aade-user-id";
myRequest..Header["Ocp-Apim-Subscription-Key"] = "subscription key";
myRequest..Content = "body";
myResponse is httpResponse = HTTPSend(myRequest);
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
Info(myResponse..Content);
END
Re: Curl to WinDEV
September 07, 2020 08:29PM
Hi Adelo,

thanks for the code

Regards
Steven Sitas
Peter Holemans
Re: Curl to WinDEV
September 08, 2020 10:02AM
Hi Steve

As curl is targeted at REST services you might use the RESTRequest and RESTResponse variables instead.

Best regards

Peter H.
Re: Curl to WinDEV
September 08, 2020 06:51PM
Hi Peter,

yes I am using the code ADELO posted above and it works fine - he is using RESTRequest and RESTRespone ...
Previously I tried to do authorization with myRequest..user and myRequest..password in the REST request and ofcourse it didn't work.
You need to pass "aade-user-id" and "Ocp-Apim-Subscription-Key" in the header to make things like this to work

Regards
Steven Sitas
Boubacar
Re: Curl to WinDEV
February 21, 2023 09:39AM
curl -k -H 'Accept: application/json' -H "Authorization: Bearer ${my_token}" [api.sandbox.orange-sonatel.com]${your_msisdn}
Re: Curl to WinDEV
March 08, 2023 10:48AM
Hi,

I have the same question with following code:

curl -H "Authorization: Bearer token_api_oauth" \
"[api.smsapi.com]?\
from=sender_name&\
to=44123456789&\
message=message_content&\
format=json"

Regards

Vassilis Boutsikas
Re: Curl to WinDEV
March 22, 2023 12:31PM
Hi,

I'd like to convert this curl code to WL

curl -H "Authorization: Bearer token_api_oauth" \
"[api.smsapi.com]?\
from=sender_name&\
to=44123456789&\
message=message_content&\
format=json"

Any idea?

Thank you in advance

Vassilis Boutsikas
pao
Re: Curl to WinDEV
March 22, 2023 03:25PM
Try something like this, not tested and probably with compilation errors:

cMyRequest is httpRequest
cMyRequest..URL = "[api.smsapi.com]?from=sender_name&to=44123456789&message=message_content&format=json"
cMyRequest..Header["Authorization"]="Bearer "+token_api_oauth
cMyRequest..IgnoreError = cMyRequest..IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirection+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS+httpIgnoreRevocation
cMyRequest..Method=httpGet
cMyResponse is httpResponse = HTTPSend(cMyRequest)

Regards

Paulo Oliveira
Re: Curl to WinDEV
March 23, 2023 11:35AM
Hi Pao,

I'll try the code.

Thank you

Vassilis Boutsikas
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: