I apreciate your comment! I put "\r\n" but I still got the html page as result, I am expeting receive:
{"responseParameters":{"doui_setResponseParameters":["8AA8D0CD6A05153A016A16735AF94E0E"]}}
If you have any other suggestion, I spent the weekend tring to receive this message :(
void OnStart() { string cookie=NULL,referer=NULL,headers="",header; char post[],result[]; //url string url="http://www.b3.com.br/main.jsp?lumPageId=8A488AE9543E47C601543FA7E9807C6F&lumA=1&lumII=8A488AE9543E47C601543FA9249D027A&doui_processActionId=commit&doui_fromForm=Form_8A488AE9543E47C601543FA9249D027A"; char data[]; //header header="Accept:application/json, text/javascript, */*; q=0.0\r\nContent-Type:application/x-www-form-urlencoded\r\n"; //data // StringToCharArray("dataDownload=12%2F04%2F2019&tipo=PE",data); StringToCharArray("dataDownload:12/04/2019&tipo:PE",data); int res=WebRequest("POST",url,header,10000,data,result,headers); string mais= CharArrayToString(result); if(res==-1) { Print("Erro no WebRequest. Código de erro =",GetLastError()); //--- é possível que a URL não esteja na lista, exibimos uma mensagem sobre a necessidade de adicioná-la MessageBox("É necessário adicionar um endereço '"+url+"' à lista de URL permitidas na guia 'Experts'","Erro",MB_ICONINFORMATION); } else { if(res==200) { //--- download bem-sucedido PrintFormat("O arquivo foi baixado com sucesso, tamanho %d bytes.",ArraySize(result)); //PrintFormat("Cabeçalhos do servidor: %s",headers); //--- salvamos os dados em um arquivo int filehandle=FileOpen("url.txt",FILE_WRITE|FILE_BIN); if(filehandle!=INVALID_HANDLE) { //--- armazenamos o conteúdo do array result[] no arquivo FileWriteArray(filehandle,result,0,ArraySize(result)); //--- fechamos o arquivo FileClose(filehandle); } else Print("Erro em FileOpen. Código de erro =",GetLastError()); } else PrintFormat("Erro de download '%s', código %d",url,res); } }
Just to you see I did a very single macro on excel with the same parameters, if you run it it goes ok, this shows that the parameters are ok
Sub macroPOST() Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP") Url = "http://www.b3.com.br/main.jsp?lumPageId=8A488AE9543E47C601543FA7E9807C6F&lumA=1&lumII=8A488AE9543E47C601543FA9249D027A&doui_processActionId=commit&doui_fromForm=Form_8A488AE9543E47C601543FA9249D027A" objHTTP.Open "POST", Url, False objHTTP.setRequestHeader "Accept", "application/json" objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.Send ("dataDownload=12/04/2019&tipo=PE") replyTXT = objHTTP.responseText If objHTTP.Status = "200" Then 'success MsgBox replyTXT Else 'Do something End If End Sub
I apreciate your comment! I put "\r\n" but I still got the html page as result, I am expeting receive:
{"responseParameters":{"doui_setResponseParameters":["8AA8D0CD6A05153A016A16735AF94E0E"]}}
If you have any other suggestion, I spent the weekend tring to receive this message :(
I have checked the strings on WS it is the same, it is very strange, I really lost my head trying solve it, in VBA excel and POSTMAN it works, but in mql5 not, I found some related posts like this
https://www.mql5.com/en/code/12296 but got no solution.
What do you recommend in this case? it looks to be a bug, I tried every possible combination, no results.
- www.mql5.com
I have checked the strings on WS it is the same, it is very strange, I really lost my head trying solve it, in VBA excel and POSTMAN it works, but in mql5 not, I found some related posts like this
https://www.mql5.com/en/code/12296 but got no solution.
What do you recommend in this case? it looks to be a bug, I tried every possible combination, no results.
I apreciate your comment! I put "\r\n" but I still got the html page as result, I am expeting receive:
{"responseParameters":{"doui_setResponseParameters":["8AA8D0CD6A05153A016A16735AF94E0E"]}}
If you have any other suggestion, I spent the weekend tring to receive this message :(
Well I can post later the results from wire shark but I created a order, only the file I'd will be enough.
https://www.mql5.com/en/job/97010
- www.mql5.com
Well I can post later the results from wire shark but I created a order, only the file I'd will be enough.
https://www.mql5.com/en/job/97010
Have you figured out what was the problem?
I encountered a similar issue
postman works as expected, WebRequest does not
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to use WebRequest to send a header and get a response. Basically I have the follow parameters:
url: "http://www.b3.com.br/main.jsp?lumPageId=8A488AE9543E47C601543FA7E9807C6F&lumA=1&lumII=8A488AE9543E47C601543FA9249D027A&doui_processActionId=commit&doui_fromForm=Form_8A488AE9543E47C601543FA9249D027A"
header="Accept:application/json, text/javascript, */*; q=0.0\r\nContent-Type:application/x-www-form-urlencoded"
data:"dataDownload:12/04/2019&tipo:PE"
If I put this parameters on POSTMAN, exactly as it is I get the response:
{"responseParameters":{"doui_setResponseParameters":["8AA8D0CD6A05153A016A16735AF94E0E"]}}
But Whe I try a single script with WebRequest() I only receive the web site html code:
I really,really,really apreciate if someone can help me.