Skip to content
⌘ NSIS Forum Archive

HTTP GET request

20 posts

Re DeL SiLeNziO#

HTTP GET request

Hi all,
I've a problem in order to perform an HTTP GET request by nsis..
I should perform this request with a parameter, that will be a json. Now, I've made the json with the correct values, but I don't know how can I perform the GET request.. any ideas?!?

Thanks so much! 👍
Anders#
This is not really a NSIS question.

How you pass the data will depend on the server but in general you should probably use POST if you are sending JSON to the server...
jpderuiter#


For JSON post:


Not sure how to set Content-Type as application/jsonrequest with this plugin though...
Anders#
Originally Posted by jpderuiter View Post
Not sure how to set Content-Type as application/jsonrequest with this plugin though...
/HEADERS probably...
jpderuiter#
The /HEADER parameter is not available for post (at least not mentioned on the wiki page).
Anders#
I would assume that /HEADER works with post but to find out for sure you would either have to just test or take a look at the source code...
jpderuiter#
I just checked in the source code, /HEADER parameter is available for post, so you could try that.
Re DeL SiLeNziO#
So.. I've problems again..
I'm trying to use post:

inetc:😛ost /header \
"Host 127.0.0.1:4488 \
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 \
Content-Type application/json; charset=UTF-8" \
/file c:\Temp\test.json \
"http://127.0.0.1:4488/"
and I've trapped the return error with:

Pop $1 # return value = exit code, "OK" if OK
MessageBox MB_OK "Status: $1"
and it returns: "Connection Error".

I would like to exclude that the post syntax is uncorrect, could you confirm it?
Anders#
I don't think you should add the Host header, the plugin/WinINet will probably add it. You probably also need to add $\r$\n for each header.

Do you get connection error if you don't use /header?
Re DeL SiLeNziO#
Without /header I obtain "parts error"...
So in this moment I'm trying with :

inetc:😛ost /header "Content-Type:application/json" "$jSonTree" "http://127.0.0.1:4488" "$output" /end
but it doesn't work correctly.. what do you mean with $\r$\n ??

Thanks!
Re DeL SiLeNziO#
Ok with this call:
inetc:😛ost /header "Content-Type:application/json" "$jSonTree" "http://127.0.0.1:4488" /end
it works and after do that, the return value of the post is "OK", but... if I try to analyze the traffic on 4488 port.. nothing!

the inetc:😛ost works?? Someone else using this method?!
I've tried to simulate my call with wget, using a file containing my json:

C:\Utilities\GnuWin32\bin\wget.exe -v --header=Content-Type:application/json --post-file C:\Temp\test.json http://127.0.0.1:4488
and it works!

Any ideas?! 🧟😐😱
Re DeL SiLeNziO#
Yeah, I've already thought this.. and traffic doesn't pass from localhost:4488... :-(
I don't know... 🙁 any ideas?
I've seen in the source code that post calls directly the get fuction... now i'm trying to use directly get.. but... I don't know if it is a good idea...
Anders#
You could try a different server, I believe there are some online services that allow you to test this kind of stuff by responding with the headers and post data in their returned page, or just run the server on a different machine...
Re DeL SiLeNziO#
but with wget works with this server...
I'm going to search a test server...

thanks for the patience!