send a json with webrequest

 

I wanna send this json with webrequest in mql5

{'ticket_num':ticket,
'identifier':identifier,
'entry1':entry1,
'entry2':entry2,
'entry3':entry3,
'sl':sl,
'tp1':tp1,
'tp2':tp2,
'tp3':tp3,
'direction':direction,
'symbol':symbol,
'lot_size':lot_size,
'time':time}

and doucumantaion have this code below but i dont know where to put the json data

   string cookie=NULL,headers;
   char   post[],result[];
   string url="https://finance.yahoo.com";
//--- To enable access to the server, you should add URL "https://finance.yahoo.com"
//--- to the list of allowed URLs (Main Menu->Tools->Options, tab "Expert Advisors"):
//--- Resetting the last error code
   ResetLastError();
//--- Downloading a html page from Yahoo Finance
   int res=WebRequest("GET",url,cookie,NULL,500,post,0,result,headers);

 
You can only send it with GET when part of the URL

Else you will need to POST or PUT your data.



 
Dominik Egert #:
You can only send it with GET when part of the URL

Else you will need to POST or PUT your data.



GET can send body there is not technical difficulty or rule against , kindly tell me if there any rule against it.

 
Farrukh Aleem #:

GET can send body there is not technical difficulty or rule against , kindly tell me if there any rule against it.

thanke  you for the answer 

i am new to mql sorry for that if disturib you 


i dont get it how can i put these data in the url??

there is no way to send a json data with post request??

 
Farrukh Aleem #:

GET can send body there is not technical difficulty or rule against , kindly tell me if there any rule against it.

if you show me with my code i'm really be thankful bro
 
Dominik Egert #:
You can only send it with GET when part of the URL

Else you will need to POST or PUT your data.



hi 

thanks for your answer 

could you please how to do it with my json and give me an example

 
Here, and if you had have read the wiki, you would have read this:

"The GET method requests that the target resource transfers a representation of its state. GET requests should only retrieve data and should have no other effect. (This is also true of some other HTTP methods.)[1] For retrieving resources without making changes, GET is preferred over POST, as they can be addressed through an URL, which enables bookmarking and sharing, and makes GET responses eligible for caching, thus can save bandwidth. The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations."[53] See safe methods below."


So, yes, GET is for non changing source operations.
 
Let me Google that for you.



 
Dominik Egert #:
Here, and if you had have read the wiki, you would have read this:

"The GET method requests that the target resource transfers a representation of its state. GET requests should only retrieve data and should have no other effect. (This is also true of some other HTTP methods.) [1]For retrieving resources without making changes, GET is preferred over POST, as they can be addressed through an URL, which enables bookmarking and sharing, and makes GET responses eligible for caching, thus can save bandwidth. The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations." [53]See safe methods below."


So, yes, GET is for non changing source operations.


Get request can send body payload and can receive it too that's what i am trying to tell. The word used in above definition is "should be" so responsibility not to change data in this case for good practice lies on developer.

 
Ali Mahdiyar #:

hi 

thanks for your answer 

could you please how to do it with my json and give me an example

create a proper url encoded string like

string strJsonText = "{\r\n\"key\": \"value\"\r\n}";

and just append it to a variable in url. 

you can use json encode and url encode functions too if they are available to you.

 
Btw, your URL is not proper encoded.
Ever heard the term Base 64?

Developers have developed this "should be".

Technically you could also have a logistics company with Ferraris...

GET statements are bound to be cached, but why should I discuss this.

You asked, I answered.

Do as you like, I don't care...