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)
아래에 의견을 추가하고 토론에 참여하세요.
Yes, get the right mashape key and you can use it now.
It still isn’t working for me. Maybe we can get Mashape involved.
I am closing the comment now, thanks
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”: “???”
}
)
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’}
I regenerated the key and changed to double quotes. Now I am getting this:
It seems the mashape key you use is not invalide
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]:
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”:"???"}’) )
Thank you for your help. I anxiously await the resolution.