Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, 1 invisible), 601 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Zorro and Mattermost by http_send()? #483343
05/21/21 13:04
05/21/21 13:04
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

do you anybody know, how to send msg to Mattermost?

In the python I use this code:
Code
    headers = {'Content-Type': 'application/json',}
    try:
        main()
    except:
        values =  '{ "text": "Exception on re4mt4"}'
        requests.post('https://4xcd.cloud.mattermost.com/hooks/pmjiwyb............x', headers=headers, data=values) 


but in the Zorro this not work. My code:
Code


void sendMTS(){
    
    string Header="{'Content-Type': 'application/json',}";   
    string Code = "{ \"text\": \"Exception on Zorro :\"}";
    string URL = "https://4xcd.cloud.mattermost.com/hooks/pmj...........x";
    int handle=http_send (URL,  Code, Header);
    printf("\nSTAT: %d",http_status(handle));   // return 173
    http_free(handle);
}

function run() {
    printf("Run testing..");
    sendMTS();
    wait(1000);
    quit("");
}

Re: Zorro and Mattermost by http_send()? [Re: Grat] #483348
05/21/21 14:29
05/21/21 14:29
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Http headers do not use the formatting you show.
https://datatracker.ietf.org/doc/html/rfc2616#section-4.2
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
Quote
Header fields are colon-separated key-value pairs in clear-text string format, terminated by a carriage return (CR) and line feed (LF) character sequence.

More like this:
Code
"key1:value1\r\nkey2:value2\r\nkey3:value3"

Re: Zorro and Mattermost by http_send()? [Re: Grat] #483351
05/22/21 08:54
05/22/21 08:54
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
finally - this example work:

Code
void sendMTS(string cIn){
  
    string Header="Content-Type:application/json";   
    string Code = strf("{\r\n\"text\": \"Error - %s\"\r\n}",cIn);
    string URL = "https://4xcd.cloud.mattermost.com/hook/.....";
    int handle=http_send (URL,  Code, Header);
    printf("\nSTAT: %d",http_status(handle));

  http_free(handle);
}

function run() {
    printf("Run testing..");
    sendMTS("Test");
    wait(1000);
    quit("");
}


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1