HTTP response body

HTTP response body SearchSearch
Author Message
Mohamed Almsalati
New member
Username: Almsalati

Post Number: 1
Registered: 06-2022
Posted on Monday, June 27, 2022 - 11:35 pm:   

Hi,

We have a query regarding the HTTP response body.

We use this URL to send messages to the Nowsms app
http://servername:8800/path? PreAuth = Reject & Type = SMSSend & From = Sender & To = Receiver & MsgCount = 1 & SubmitIP = 127.0.0.1 & Text = simpleMassage & password = password & user = User & ReceiptRequested = Yes

It is also used in
SMSAccountingPreAuthPerRecip = Yes
In the SMSGW file.

Currently, SMPP errors and statistics are only returned in the log file and not in the response body. As shown in the attached files
\popattach 114039,log file return now
\poppng 114040,HTTP response body now..

We want to return SMPP error and Stat in the HTTP response body because only MessageID & Recipient is currently returned.

Another question: How to change the HTTP response body from HTML to XML or JSON?



Thanks}
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 6329
Registered: 08-2008
Posted on Tuesday, June 28, 2022 - 04:00 pm:   

Hi,

Unfortunately, something went wrong with uploading your attachments. They might have helped me understand what you are asking.

Are you trying to implement accounting callbacks?

Or are you trying to use this URL to submit a message to NowSMS?

This does not look like a URL for submitting a message. It looks like an SMS accounting callback. It might work to send a message, but why are there PreAuth=, Type=, MsgCount=, SubmitIP= … these parameters do not belong. They belong if this is an accounting call from NowSMS, but they do not belong if this is a user created URL to NowSMS.

Submitting to NowSMS:

https://nowsms.com/doc/submitting-sms-messages/sending-sms-text-messages

https://nowsms.com/doc/submitting-sms-messages/url-parameters

Accounting callback info:

https://nowsms.com/doc/advanced-configuration-settings/sms-accounting-callbacks


Regards,

Des
NowSMS Support

P.S. - Apologies in advance, but several key members of our tech support staff are unavailable this week, and I expect delays responding to follow up questions.
Mohamed Almsalati
New member
Username: Almsalati

Post Number: 2
Registered: 06-2022
Posted on Tuesday, June 28, 2022 - 06:33 pm:   

Thank you Des for the quick reply

To make it clear to you, I want to send a message via HTTP, but the response body returns an HTML.
My question is how to change the return HTML to XML or JSON?
http response body

Currently, as shown in the attached image, it is in the HTTP response body only MessageID & Recipient are returned.

Can the SMPP error and Stat be returned in the HTTP response body as it is returned in the SMSOUT-20220627.LOG file?

For example on the log:

2022-06-27 09:47:36:373,62B2E5D1,172.16.124.90,218919423842,OK -- SMPP - 41.208.113.118:9999,SubmitUser=1001191;SMSCRouteName=madar;Sender=10100;SMSCMsgId=621FE15C;Text= "hik".

2022-06-27 09:47:39:385,62B2E5D2,,10100,OK -- LocalUser:1001191,SubmitUser=SMPP - 41.208.113.118:9999;Sender=218919423842;Text="id:62B2E5D1 sub:001 dlvrd: 001 submit date:2206270942 done date:2206270942 stat:DELIVRD err:000 text:hikk".

I hope you understand me

Thanks and BR}
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 6330
Registered: 08-2008
Posted on Thursday, June 30, 2022 - 02:06 am:   

Hi,

Thanks, I understand.

In the Linux version of NowSMS, this is possible. But unfortunately, I do not have a document that explains this, which means that i will probably have to write it.

My understanding is that you use HTTP POST and specify a content-type of application/json or text/json. Instead of encoding the message data in the request body in JSON format, instead of URL parameters. Use the same parameter names, but encode as a JSON request.

Unfortunately, I’m not experienced with using JSON, so I am waiting for one of my colleagues with JSON experience to provide a more detailed explanation. But perhaps the short explanation above will provide a clue that will help you.

Regards,

Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 6331
Registered: 08-2008
Posted on Thursday, June 30, 2022 - 07:40 pm:   

Hi,

Sorry for taking so long to explain this.

I will use your example and show how to make the request in JSON format.

All versions of NowSMS support message submission via HTTP with URL encoded parameters using HTTP GET or POST. The example in your post uses HTTP GET:

http://172.16.68.32:8800/?User=1001191&Password=123456&PhoneNumber=218919423842&Text=Hello

As you have noted, the response from NowSMS is awkward to process because it is encoded in HTML format. There are some examples of how to parse the response, such as this post: https://support.nowsms.com/discus/messages/1/24868.html

The Linux version of NowSMS also allows HTTP based message submission using JSON or XML via HTTP POST, and in these cases, the HTTP response will also use JSON or XML, matching the encoding of the request.

To submit a message to NowSMS using JSON, you must use HTTP POST with a "Content-Type:" header of application/json. The variable values should be JSON encoded in the request body. For example:

{"PhoneNumber":"218919423842","text":"Hello"}

IMPORTANT NOTE: The "User" and "Password" variables used for authentication cannot be included in the JSON request. The preferred solution for authentication is to include an HTTP Authorization header using HTTP basic authentication (base64 authentication). NowSMS will also support the "User" and "Password" values remaining in the URL, for example, posting the JSON request {"PhoneNumber":"218919423842","text":"Hello"} to URL http://172.16.68.32:8800/?User=1001191&Password=123456

The JSON response from NowSMS will be formatted like this:

{ "status":"OK", "statusdetail":"", "messages": [ { "messageid":"6035E649", "recipient":"218919423842" }] }

Note that "messages" is an array. There will only be one object in this array unless a message was submitted to multiple recipients, which are comma delimited, for example: {"PhoneNumber":"218919423842, 218919423843","text":"Hello"}

The "status" in the response only indicates that the message was accepted by NowSMS. Delivery reports may be received from the upstream server(s) at a later time. These delivery reports are essentially just inbound text messages that start with "id:". These messages can be posted to your application as they are received by defining 2 way commands.

Regards,

Des
NowSMS Support

Add Your Message Here, or click here to start a new topic.
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image
Options: Automatically activate URLs in message
Action: