-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (46 loc) · 1.46 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const http = require('node:http');
const postData = JSON.stringify({
"subscription": {
"callbackReference": {
"notifyURL": "http://ApplicationIP/Client IP:PORT/",
"callbackData": 123,
"notificationFormat": "json"
},
"destinationAddress": 1234,
"criteria": "order"
}
});
const options = {
hostname: ' Server IP',
port: PORT_number,
path: '/1/smsmessaging/inbound/subscriptions'
method: 'POST',
headers: {
'Accept': 'application/json',
'Authorization': 'WSSE realm="SDP", profile="UsernameToken"',
'X-WSSE': 'UsernameToken Username="username", PasswordDigest="H1JehEGk7J9VIIb5Hlvcz5QZg6U=", Nonce="66C92B11FF8A425FB8D4CCFE0ED9ED1F", Created="2023-10-19T10:04:32Z"',
'Content-Type': 'application/json',
'Content-Length': 1024 ,
'Connection': 'keep-alive',
'X-RequestHeader': 'request'
},
};
const req = http.request(Option, (res) => {
console.log(`STATUS: ${res.statusCode}`);
console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
res.setEncoding('utf8');
res.on('data', (chunk) => {
console.log(`BODY: ${chunk}`);
});
res.on('end', () => {
console.log('No more data in response.');
});
});
req.on('error', (e) => {
console.error(`problem with request: ${e}`);
console.log(JSON.stringify(e))
});
// Write data to request body
req.write(postData);
console.log(req.headers);
req.end();