Archive: HTTP GET request


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:


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...


Ok, but there is a syntax to do a POST or a GET with NSIS?!


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...


Originally posted by jpderuiter
Not sure how to set Content-Type as application/jsonrequest with this plugin though...
/HEADERS probably...

The /HEADER parameter is not available for post (at least not mentioned on the wiki page).


So.. I'm confused.. Now I'm going to try with this plugin... waiting for updates!


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...


It's an hardest world, NSIS world... :(


I just checked in the source code, /HEADER parameter is available for post, so you could try that.


Thanks! I'm going to try...


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?

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?


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!

Sorry, I want to say that I obtain File Open Error
but which file???


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:

You could try Wireshark...


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...


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...


but with wget works with this server...
I'm going to search a test server...

thanks for the patience!