Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 3 Monaten, 2 Wochen
Letzter Beitrag:
vor 3 Monaten, 2 Wochen
Beteiligte Autoren:
Luis Antonio Gutiérrez Flores, Fabrice Harari

[WB22] WebDev and cURL

Startbeitrag von Luis Antonio Gutiérrez Flores am 29.08.2017 16:52

Has anyone used cURL in webdev? I'm trying to make requests by using restRequest and restResponse variables, but without success, the server is responding but it always says that my keys are wrong, which aren't, here is my code:
cMyRequest is restRequest
cMyRequest..URL = "https://sandbox-api.openpay.mx/v1/{merchant_ID}/charges"
cMyRequest..Content = "-u {private_key}"
cMyRequest..ContentType = typeMimeJSON
cMyRequest..Method = httpPost
cMyResponse is restResponse = RESTSend(cMyRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
Info(cMyResponse..Content)
END

The documentation for cURL is as follows:
Authentication example
curl https://sandbox-api.openpay.mx/v1/mzdtln0bmtms6o3kck8f/charges \
-u sk_e568c42a6c384b7ab02cd47d2e407cab:

Antworten:

Hi Luis,

AFAIK, this part: cMyRequest..URL = "{merchant_ID}/charges"

is NOT a valid URL part

So either you need to replace it with something, or it need to be part of the post string

Best regards

von Fabrice Harari - am 29.08.2017 17:02
Yes! I'm replacing it with information of my client, and it ends up something like this:

https://sandbox-api.openpay.mx/v1/mzdtln0bmtms6o3kck8f/charges

von Luis Antonio Gutiérrez Flores - am 29.08.2017 17:04
Solved it! Still needs more coding, but could get past the error I was getting thanks to Uncle Pete (Pete Halsted)
Here is my code:

vCharge is Variant
vCharge.method = "card"
vCharge.amount = 100
vCharge.description = "Cargo de prueba"
sCharge is string = VariantToJSON(vCharge)


cMyRequest is restRequest
cMyRequest..URL = "https://sandbox-api.openpay.mx/v1/***********/charges"; //* is the Merchant_ID
cMyRequest..User = "*******************" //Private API key
cMyRequest..ContentType = typeMimeJSON
cMyRequest..Method = httpPost
cMyRequest..Content = sCharge
cMyResponse is restResponse = RESTSend(cMyRequest)
IF ErrorOccurred THEN
Error(ErrorInfo(errFullDetails))
ELSE
Info(cMyResponse..Content)
END

von Luis Antonio Gutiérrez Flores - am 29.08.2017 17:25
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.