Copy
curl --request POST \
--url https://api.symlix.com/v1/sendMessage \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: API key' \
--header 'content-type: application/x-www-form-urlencoded' \
--data tradeId=2423 \
--data message=Test
Copy
$request = new HttpRequest();
$request->setUrl('https://api.symlix.com/v1/sendMessage');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'accept' => 'application/json, text/plain, */*',
'content-type' => 'application/x-www-form-urlencoded',
'authorization' => 'API key'
]);
$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields([
'tradeId' => '2423',
'message' => 'Test'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Copy
import http.client
conn = http.client.HTTPSConnection("api.symlix.com")
payload = "tradeId=2423&message=Test"
headers = {
'accept': "application/json, text/plain, */*",
'content-type': "application/x-www-form-urlencoded",
'authorization': "API key"
}
conn.request("POST", "/v1/sendMessage", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Copy
fetch("https://api.symlix.com/v1/sendMessage", {
"method": "POST",
"headers": {
"accept": "application/json, text/plain, */*",
"content-type": "application/x-www-form-urlencoded",
"authorization": "API key"
},
"body": {
"tradeId": "2423",
"message": "Test"
}
})
.then(response => {
console.log(response);
})
.catch(err => {
console.error(err);
});
Copy
const qs = require("querystring");
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.symlix.com",
"port": null,
"path": "/v1/sendMessage",
"headers": {
"accept": "application/json, text/plain, */*",
"content-type": "application/x-www-form-urlencoded",
"authorization": "API key"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(qs.stringify({tradeId: '2423', message: 'Test'}));
req.end();
Copy
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.symlix.com/v1/sendMessage"
payload := strings.NewReader("tradeId=2423&message=Test")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("accept", "application/json, text/plain, */*")
req.Header.Add("content-type", "application/x-www-form-urlencoded")
req.Header.Add("authorization", "API key")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}