Text-Processing

FREEMIUM
By japerk
Updated 4 months ago
Other
9.3/10
Popularity Score
523ms
Latency
75%
Success Rate
mneticjab5 years ago
Sentiment API - Form Validation Errors - Text field is requiredI am trying to run the API through the Unirest post method as given in the example. The code is as follows. HttpResponse<string> response = Unirest.Post("https://japerk-text-processing.p.mashape.com/sentiment/") .header("X-Mashape-Authorization", "<My API Key>") .field("text", "This is awesome") .field("language", "english") .asJson<string>(); However, even after a lot of trying, I get error message as "Form Validation Errors\ntext: This field is required.\n" Any quick help will be greatly appreciated as I am in urgency to get a sentiment API done.
japerk5 years ago
What language are you using? Have you tried with a different language/client library? The client library you're using is clearly not passing in the correct form fields, so maybe you can inform the unirest developers.
mneticjab5 years ago
Hai Japerk First let me thank you'll for the reply. I am using C#. Than using the Unirest Library, I tried using the generic Post method in the native MSDN method. The code is below. Then too, I received only a 403 forbidden reply. I ensured that my key is right. Any help will be appreciated. HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("https://japerk-text-processing.p.mashape.com/sentiment/"); ASCIIEncoding encoding = new ASCIIEncoding(); string postData = "X-Mashape-Authorization=<My API Key>"; postData += "&text=This is awesome"; postData += "&language=english"; byte[] data = encoding.GetBytes(newdata); httpWReq.Method = "POST"; httpWReq.ContentLength = data.Length; using (Stream stream = httpWReq.GetRequestStream()) { stream.Write(data, 0, data.Length); } HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse(); string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
ismaelc5 years ago
Hi mneticjab, please email me at [email protected] so I can help you out. Thanks
japerk5 years ago
Sorry, I thought you'd taken this issue up with Chris. Have you heard back from him?
devitsu5 years ago
Ugh, sorry about the formatting, I tried to fix it but it won't let me edit.
mneticjab5 years ago
This is Bad. Closing the issue without a solution!
community5 years ago
Hey Arun, I think I replied to you 4 days ago with the sample .NET code? Did you get it?
japerk5 years ago
No replies for a month, so I'm going to assume devitsu's solution is correct and/or the issue has been resolved.
devitsu5 years ago
Hi, (Hopefully someone else might find this useful) I had a similar issue with Unirest, the following worked for me: ```c# var httpWReq = ( HttpWebRequest )WebRequest.Create( "https://japerk-text-processing.p.mashape.com/stem/" ); httpWReq.ContentType = "application/x-www-form-urlencoded"; httpWReq.Headers[ "X-Mashape-Authorization" ] = "<API Key>"; httpWReq.Method = "POST"; var postData = "&text=This is awesome&language=english&stemmer=lancaster"; var byte1 = new ASCIIEncoding().GetBytes( postData ); httpWReq.ContentLength = byte1.Length; using ( var requestStream = httpWReq.GetRequestStream() ) { requestStream.Write( byte1, 0, byte1.Length ); requestStream.Close(); } string responseString; using ( var response = httpWReq.GetResponse() ) { using ( var loResponseStream = new StreamReader( response.GetResponseStream(), Encoding.UTF8 ) ) { responseString = loResponseStream.ReadToEnd(); loResponseStream.Close(); } }```
mneticjab5 years ago
Hai Ismaelc, Thanks for your interest. I will mail you immediately.
Hi Developer, feel free to post your answer:

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.post("https://japerk-text-processing.p.rapidapi.com/phrases/")
.header("X-RapidAPI-Host", "japerk-text-processing.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.header("Content-Type", "application/x-www-form-urlencoded")
.send("language=spanish")
.send("text=California is nice")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication