- NSIS Discussion
- HTTP GET request
Archive: HTTP GET request
Re DeL SiLeNziO
13th November 2013 15:05 UTC
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! :up:
Anders
14th November 2013 08:20 UTC
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...
Re DeL SiLeNziO
14th November 2013 08:25 UTC
Ok, but there is a syntax to do a POST or a GET with NSIS?!
jpderuiter
14th November 2013 08:28 UTC
http://nsis.sourceforge.net/Inetc_plug-in
For JSON post:
http://www.json.org/JSONRequest.html
Not sure how to set Content-Type as application/jsonrequest with this plugin though...
Anders
14th November 2013 11:27 UTC
Originally posted by jpderuiter
Not sure how to set Content-Type as application/jsonrequest with this plugin though...
/HEADERS probably...
jpderuiter
14th November 2013 13:16 UTC
The /HEADER parameter is not available for post (at least not mentioned on the wiki page).
Re DeL SiLeNziO
14th November 2013 15:17 UTC
So.. I'm confused.. Now I'm going to try with this plugin... waiting for updates!
Anders
14th November 2013 15:25 UTC
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...
Re DeL SiLeNziO
15th November 2013 10:53 UTC
It's an hardest world, NSIS world... :(
jpderuiter
15th November 2013 11:33 UTC
I just checked in the source code, /HEADER parameter is available for post, so you could try that.
Re DeL SiLeNziO
15th November 2013 13:40 UTC
Thanks! I'm going to try...
Re DeL SiLeNziO
18th November 2013 12:06 UTC
So.. I've problems again..
I'm trying to use post:
inetc::post /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
19th November 2013 06:40 UTC
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
21st November 2013 10:58 UTC
Without /header I obtain "parts error"...
So in this moment I'm trying with :
inetc::post /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
21st November 2013 11:46 UTC
Sorry, I want to say that I obtain File Open Error
but which file???
Re DeL SiLeNziO
21st November 2013 16:35 UTC
Ok with this call:
inetc::post /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::post 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?! :igor::stare::eek:
Anders
21st November 2013 17:10 UTC
You could try Wireshark...
Re DeL SiLeNziO
22nd November 2013 08:08 UTC
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
22nd November 2013 08:48 UTC
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
22nd November 2013 09:47 UTC
but with wget works with this server...
I'm going to search a test server...
thanks for the patience!