Jump to content

Executing code with http client on windows


pwired
 Share

Recommended Posts

Hi,
This is not directly related with processwire but coded related
so I hope one of you skilled coders can help me out with this one.

A friend is on mac an he can execute following command with parameters
without any problems. He can even split the command over 5 lines
by using a backslash \


-X POST \
 -H "X-Parse-Application-Id: abcdefghijklmnopqrstuvwz" \
 -H "X-Parse-REST-API-Key: abcdefghijklmnopqrstuvwxyz" \
 -H "Content-Type: application/json" \
 -d '{"accounts": ["123456789"]}' \
 https://api.domain.com/1/functions/checkAccounts


I am on windows and as far as I can get I can only use
cURL to execute the same command. First of all it seems with cURL
I can not split the command over 5 lines with a backslash \
but I have to put everything on a single line.
Second I have to use the \ as an escape character in the
JSON parameter: this won't work with cURL  -d '{"accounts": ["123456789"]}'
and I have to change it into -d "{\"accounts\": [\"123456789\"]}"
to make it work with cURL

I tried httpie and wget on windows but both do not accept the command
the way it is executed on mac, also not the way cURL is accepting it.

Besides cURL, httpie and wget, does anyone know a way how I can execute
this command on windows the same way as my friend does on mac split
over different lines and without escape characters ?

Link to comment
Share on other sites

Thanks for that hint Charles, I downloaded and installed Cygwin and can execute all the commands as shown

in the youtube video clip, just when I try to execute the command as above:

-X POST \
 -H "X-Parse-Application-Id: abcdefghijklmnopqrstuvwz" \
 -H "X-Parse-REST-API-Key: abcdefghijklmnopqrstuvwxyz" \
 -H "Content-Type: application/json" \
 -d '{"accounts": ["123456789"]}' \
 https://api.domain.c...s/checkAccounts

I get a message thrown:

-bash: -X: command not found

Link to comment
Share on other sites

Copied curl.exe to C:\cygwin\bin\

Putting curl after the cygwin terminal prompt $ does it !

Now I can execute those commands exactly the same way as on mac:

split over different lines with \ and without escape characters :)

Thanks Charles and LostKobrakai

  • Like 1
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...