TextAnalysis

FREEMIUM
By TextMiner | Updated vor 14 Tagen | Tools
Popularity

9 / 10

Latency

289ms

Service Level

100%

Health Check

N/A

Back to All Discussions

403 response

Rapid account: Webmagnets
webmagnets
vor 9 Jahren

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 vor 9 Jahren

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

Rapid account: Webmagnets
webmagnets Commented vor 9 Jahren

It still isnโ€™t working for me. Maybe we can get Mashape involved.

Rapid account: Textanalysis
textanalysis Commented vor 9 Jahren

I am closing the comment now, thanks

Rapid account: Textanalysis
textanalysis Commented vor 9 Jahren

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 vor 9 Jahren

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 vor 9 Jahren

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 vor 9 Jahren

It seems the mashape key you use is not invalide

Rapid account: Textanalysis
textanalysis Commented vor 9 Jahren

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 vor 9 Jahren

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 vor 9 Jahren

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

Join in the discussion - add comment below:

Login / Signup to post new comments