Access denied issue

Hi there, I got my subscription key today, When I tried to use it in python. I got access denied message. Can you please help here? Here is the code ########### Python 3.2 ############# import http.client, urllib.request, urllib.parse, urllib.error, base64 headers = { # Request headers 'Content-Type': 'application/json', 'Ocp-Apim-Subscription-Key': '{"f614ddd2dcf54afdb1e1abeb9c27d335"}', } params = urllib.parse.urlencode({ }) try: conn = http.client.HTTPSConnection('api.agolo.com') conn.request("POST", "/nlp/v0.2/summarize?%s" % params, "{body}", headers) response = conn.getresponse() data = response.read() print(data) conn.close() except Exception as e: print("[Errno {0}] {1}".format(e.errno, e.strerror)) #################################### Output is - b'{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }' If I use my subscription code without curly brackets 'Ocp-Apim-Subscription-Key': 'f614ddd2dcf54afdb1e1abeb9c27d335', Then I am getting error as b'{"statusCode":500,"message":"Unexpected character (\'b\' (code 98)): was expecting double-quote to start field name\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@148b9a1a; line: 1, column: 3]"}'

Attachments

Comments

  •  
    Hi Manikanta, You have an issue with the request’s body. Unexpected character (\'b\' (code 98)) was referring to {body}'s “b" Please use the attached file as an exmaple of a python request to the API.
    Posted by Hidden Tue, 16 Jan 2018 14:30:05 GMT
  •  
    Thanks, it worked. Do you have any documents related to Python with Agolo API? if yes, would you please share with me? Thanks
    Posted by Hidden Wed, 17 Jan 2018 13:46:41 GMT


You're not signed in. Please sign-in to report an issue or post a comment.