Error codes

Error codes SearchSearch
Author Message
Anonymous
 
Posted on Wednesday, March 10, 2004 - 09:44 am:   


When submiting messages to nowsms through HTTP GET
requests is there a way to get a return code if everything is ok or something wrong(like invalid parms)?

Thanks

Steve
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2053
Registered: 10-2002
Posted on Wednesday, March 10, 2004 - 01:38 pm:   

Hi Steve,

If there is a problem with the submission (invalid parameters, account over quota, etc.), then the HTTP status code that is returned will signify an error. In other words, the HTTP response code will be something other than the standard "200 OK". The text of the response will also include "Error:" or "ERROR:".

There is an exception to this. If the "User-Agent" string that was used to make the HTTP request includes the text "Mozilla", then we still return "200 OK", even if there is an error, and rely on the text of the response to describe the error condition. The reason for this is because PC web browsers generally always include the text "Mozilla" somewhere in their "User-Agent" string, and if an error code is returned to many PC web browsers, they will display a canned error message, and not the error returned by the web server itself.

So make sure that you don't include the text "Mozilla" in your "User-Agent:" header (or don't include a "User-Agent:" header), and you can rely on the HTTP status code.

-bn
Steve
Unregistered guest
Posted on Wednesday, March 10, 2004 - 05:00 pm:   


Bryce

I just connect a socket to 127.0.0.1 port 8800
and send the string

"GET /?Number=%2B3579948XXXX&Text=test HTTP/1.0"
PhoneNumber changed on purpose





what i receive is this


HTTP/1.0 200 OK
Content-type: text/html

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<title>Now SMS</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author> </o:Author>
<o:Template>Normal</o:Template>
<o:LastAuthor> </o:LastAuthor>
<o:Revision>6</o:Revision>
<o:TotalTime>0</o:TotalTime>
<o:Created>2002-10-09T15:06:00Z</o:Created>
<o:LastSaved>2002-10-09T15:57:00Z</o:LastSaved>
<o:Pages>1</o:Pages>
<o:Words>9</o:Words>
<o:Characters>53</o:Characters>
<o:Company> </o:Company>
<o:Lines>1</o:Lines>
<o:Paragraphs>1</o:Paragraphs>
<o:CharactersWithSpaces>61</o:CharactersWithSpaces>
<o:Version>10.2625</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<frameset framespacing=0 frameborder=0 border=0 cols="233,1*">
<frame name=LeftFrame src=TOCFrame.htm style='mso-linked-frame:auto'>
<frame name=MainFrame src="Send%20Text%20Message.htm" style='mso-linked-frame:
auto'>
<noframes>
<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>
<p class=MsoNormal>This page uses frames, but your browser doesn't support
them.</p>
</div>
</body>
</noframes>
</frameset>

</html>


Any suggestions

Thanks

Steve
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2064
Registered: 10-2002
Posted on Wednesday, March 10, 2004 - 08:08 pm:   

Steve,

Ah ... you're right, I hadn't considered that in my previous reponse.

If there is no "Phone=" or "PhoneNumber=" parameter present in the request, then the system treats this as a "web menu" request, and it will return the web user interface.

If you're not using this web menu interface, and are only generating requests through your own application, then this interface can be disabled, and you would get back an error code in this situation. ("Web" page of NowSMS configuration dialog, uncheck "Enable menu driven web interface")

-bn
Steve
Unregistered guest
Posted on Thursday, March 11, 2004 - 07:53 am:   

Bryce

After disabling the web interface and sending the same string

"GET /?Number=%2B3579948XXXX&Text=test HTTP/1.0"

this is what i get.

HTTP/1.0 400 Bad Request
Content-type: text/html
Expires: Tue, 01 Jan 1980 1:00:00 GMT
Cache-Control: no-cache

<HTML><HEAD><TITLE>
Unknown Request
</TITLE></HEAD><BODY><H1>
Error: Menu not enabled
</H1></BODY></HTML>

The returned code dosn't provide enough info.
It would be nice if it returned specific information especially for mandatory arguments like originator or invalid arguments


Thanks
Steve
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 2074
Registered: 10-2002
Posted on Thursday, March 11, 2004 - 06:03 pm:   

Steve,

If you're after a specific error code for each different condition, unfortunately there is not one.

Most of the error conditions return an error code 400.

403 errors are returned for account quota errors or access from invalid IP addresses.

401 is used to request an "Authorization" header (or invalid username/password in authorization header).

Then there are some 500 errors which relate to configuration errors.

-bn