TextAnalysis

פרמיום
על ידי TextMiner | מְעוּדכָּן 24 days ago | Tools
פּוֹפּוּלָרִיוּת

9 / 10

חֶבִיוֹן

297ms

רמת שירות

100%

Health Check

N/A

חזרה לכל הדיונים

403 response

Rapid account: Webmagnets
webmagnets
9 years ago

I am getting a <Response [403]> with this code:

#coding: utf-8
import requests
req = requests.request('POST','https://textanalysis.p.mashape.com/segmenter',
  headers={
           'X-Mashape-Key': 'Ia8030aCGGmshlLqLozAf9XERsUQp12ChEhjsnU5MERfwzB07',
           'Content-Type': 'application/json'
           },
  params={
          'text':'??????'
          }
)
print(req)
Rapid account: Textanalysis
textanalysis Commented 9 years ago

Yes, get the right mashape key and you can use it now.

Rapid account: Webmagnets
webmagnets Commented 9 years ago

It still isn’t working for me. Maybe we can get Mashape involved.

Rapid account: Textanalysis
textanalysis Commented 9 years ago

I am closing the comment now, thanks

Rapid account: Textanalysis
textanalysis Commented 9 years ago

I have changed the Json Request by the Form format, you can find it how to use it in the document, like this:

curl -X POST --include “https://textanalysis.p.mashape.com/segmenter
-H “X-Mashape-Key: You mashape key”
-H “Content-Type: application/x-www-form-urlencoded”
-d “text=???”

or Python:

response = unirest.post(“https://textanalysis.p.mashape.com/segmenter”,
headers={
“X-Mashape-Key”: “Your mashape key”
“Content-Type”: “application/x-www-form-urlencoded”
},
params={
“text”: “???”
}
)

Rapid account: Textanalysis
textanalysis Commented 9 years ago

Sorry, but if I use my key like this, I got the right response:

In [98]: response = unirest.post(“https://textanalysis.p.mashape.com/segmenter”, headers={“X-Mashape-Key”:“replace with your mashape key here”,“Content-Type”:“application/json”}, params=(’{“text”:"???"}’) )

In [99]: response.code
Out[99]: 200

In [100]: response.body
Out[100]: {u’result’: u’\u8fd9 \u662f \u4e2d\u6587 \u6d4b\u8bd5’}

Rapid account: Webmagnets
webmagnets Commented 9 years ago

I regenerated the key and changed to double quotes. Now I am getting this:

<Response [400]>
{u’description’: u’The browser (or proxy) sent a request that this server could not understand.’}
Rapid account: Textanalysis
textanalysis Commented 9 years ago

It seems the mashape key you use is not invalide

Rapid account: Textanalysis
textanalysis Commented 9 years ago

In [92]: response = unirest.post(“https://textanalysis.p.mashape.com/segmenter”, headers={“X-Mashape-Key”:“Ia8030aCGGmshlLqLozAf9XERsUQp12ChEhjsnU5MERfwzB07”,“Content-Type”:“application/json”}, params=(’{“text”:"???"}’) )

In [93]: response.code
Out[93]: 403

In [94]: response.body
Out[94]: {u’message’: u’Invalid Mashape Key’}

In [95]:

Rapid account: Textanalysis
textanalysis Commented 9 years ago

You should use the unirest and double quote like this:

response = unirest.post(“https://textanalysis.p.mashape.com/segmenter”, headers={“X-Mashape-Key”:“Ia8030aCGGmshlLqLozAf9XERsUQp12ChEhjsnU5MERfwzB07”,“Content-Type”:“application/json”}, params=(’{“text”:"???"}’) )

Rapid account: Webmagnets
webmagnets Commented 9 years ago

Thank you for your help. I anxiously await the resolution.

הצטרף לדיון - הוסף תגובה למטה:

התחבר / הירשם כדי לפרסם תגובות חדשות