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)
Join in the discussion - add comment below:
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.