Convert curl to ahk

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
thalesduarte
Posts: 95
Joined: 13 Sep 2021, 06:08

Convert curl to ahk

17 Nov 2022, 06:44

Hello to everyone
I'm trying to convert this curl to ahk, but without sucess.

Anyone can help-me?

Curl CODE:

Code: Select all

curl -s https://app.omie.com.br/api/v1/financas/contapagar/ -H 'Content-type: application/json' -d '{"call":"IncluirContaPagar","app_key":"38333295000","app_secret":"fed2163e2e8dccb53ff914ce9e2f1258","param":[{"codigo_lancamento_integracao":"1668682290","codigo_cliente_fornecedor":4214850,"data_vencimento":"16/11/2022","valor_documento":100,"codigo_categoria":"2.04.01","data_previsao":"16/11/2022","id_conta_corrente":4243124}]}'

My trying with ahk code:

Code: Select all

URL := "https://app.omie.com.br/api/v1/financas/contapagar/"
oHTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("POST", URL , False)
oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)")
oHTTP.SetRequestHeader("Referer", URL)
oHTTP.SetRequestHeader("Content-Type", "application/json")

Body := "{'call':'IncluirContaPagar','app_key':'38333295000','app_secret':'fed2163e2e8dccb53ff914ce9e2f1258', 'param':[{'codigo_lancamento_integracao':'1668682290','codigo_cliente_fornecedor':4214850,'data_vencimento':'16/11/2022','valor_documento':100,'codigo_categoria':'2.04.01','data_previsao':'16/11/2022','id_conta_corrente':4243124}]}"

Try
{
oHTTP.Send(Body)
}
Try
{
postRep:=oHTTP.ResponseText
}
Catch
{
postRep := "Error"
}
msgbox %postRep%
and i got bad request.
ty to help
User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: Convert curl to ahk

17 Nov 2022, 07:01

I'm not sure if this helps, but you can simply RunWait and put curl on your command line (target parameter), including curl's parameters. You can capture the output if you put | clip at the end of it. Using AHK's Hide parameter will also hide the command shell window.
teadrinker
Posts: 4389
Joined: 29 Mar 2015, 09:41
Contact:

Re: Convert curl to ahk

17 Nov 2022, 07:09

Referer and User-Agent headers are unnecessary. JSON doesn't support single quotes.
thalesduarte
Posts: 95
Joined: 13 Sep 2021, 06:08

Re: Convert curl to ahk

17 Nov 2022, 07:20

Hello @mikeyww Thanks for the reply.
How i can do it?

@teadrinker Thanks for this observation.
User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: Convert curl to ahk

17 Nov 2022, 07:37

Here is a "Run" example from a while back. viewtopic.php?p=436722#p436722
thalesduarte
Posts: 95
Joined: 13 Sep 2021, 06:08

Re: Convert curl to ahk

17 Nov 2022, 08:14

How i can get a output response from curl?
User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: Convert curl to ahk

17 Nov 2022, 09:09

If you use | clip, then the response will be on the Windows clipboard.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 100 guests