<div><font><span style="background-color:rgba(255,255,255,0)">I am getting http error 404. I am able to access the site via telnet which eliminates network issues. Here is the code and subsequent errors</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">user/bin/python</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">import sys</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">import azure</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">import socket</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">from azure.servicebus import (</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  _service_bus_error_handler</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  )</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">from azure.servicebus.servicebusservice import (</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  ServiceBusService,</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  ServiceBusSASAuthentication</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  )</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">from azure.http import (</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  HTTPRequest,</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  HTTPError</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  )</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">from azure.http.httpclient import _HTTPClient</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">class EventHubClient(object):</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">def sendMessage(self,body,partition):</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    eventHubHost = "<a href="http://pac-ns.servicebus.windows.net">pac-ns.servicebus.windows.net</a>"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    httpclient = _HTTPClient(service_instance=self)</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    sasKeyName = "pac-pl"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    sasKeyValue = "IhkEepQPLfSy9jo6H2Yxxxxxxxxxxxxxxxxxxxx="</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue)</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request = HTTPRequest()</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request.method = "POST"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request.host = eventHubHost</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request.protocol_override = "https"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">#    request.path = "/myhub/publishers/" + partition + "/messages?api-version=20</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">14-05"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request.body = body</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request.headers.append(('Content-Type', 'application/atom+xml;type=entry;cha</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">rset=utf-8'))</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    authentication.sign_request(request, httpclient)</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    request.headers.append(('Content-Length', str(len(request.body))))</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">status = 0</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    try:</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">        resp = httpclient.perform_request(request)</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">        status = resp.status</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    except HTTPError as ex:</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">        status = ex.status</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    return status</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">class EventDataParser(object):</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">  def getMessage(self,payload,sensorId):</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    host = socket.gethostname()</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    body = "{ \"DeviceId\" : \"" + host + "\",\"SensorData\": [ "</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    msgs = payload.split(",")</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    first = True</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    for msg in msgs:</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    # print msg</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">      sensorType = msg.split(":")[0]</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">sensorValue = msg.split(":")[1]</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">      if first == True:</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">        first = False</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">      else:</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">        body += ","</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">      body += "{ \"SensorId\" : \"" + sensorId + "\", \"SensorType\" : \"" + sen</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">sorType + "\", \"SensorValue\" : " + sensorValue + " }"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    body += "]}"</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">    return body</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">hubClient = EventHubClient()</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">parser = EventDataParser()</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">hostname = socket.gethostname()</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">sensor = sys.argv[2]</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">body = parser.getMessage(sys.argv[1],sensor)</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">hubStatus = hubClient.sendMessage(body,hostname)</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"># return the HTTP status to the caller</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">print hubStatus</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">print hostname</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">print sensor</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">~/IOT/AZURE$ python send.py temperature:22,humidity:20 deviceid </span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">404</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">ubuntu</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">deviceid</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)">{ "DeviceId" : "ubuntu","SensorData": [ { "SensorId" : "deviceid", "SensorType" : "temperature", "SensorValue" : 22 },{ "SensorId" : "deviceid", "SensorType" : "humidity", "SensorValue" : 20 }]}</span></font></div><div><font><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><br></div><br><br>-- <br><div dir="ltr"><div><b>Syed Khalid</b></div>
</div><br>