Text-Processing

FREEMIUM
By Jacob | Updated 5 days ago | Text Analysis
Popularity

9.6 / 10

Latency

318ms

Service Level

100%

Health Check

N/A

Back to All Discussions

Sentiment API - Form Validation Errors - Text field is required

Rapid account: Mneticjab
mneticjab
vor 10 Jahren

I 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.

Rapid account: Japerk
japerk Commented vor 10 Jahren

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.

Rapid account: Mneticjab
mneticjab Commented vor 10 Jahren

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();
Rapid account: Ismaelc
ismaelc Commented vor 10 Jahren

Hi mneticjab, please email me at chris@mashape so I can help you out. Thanks

Rapid account: Japerk
japerk Commented vor 10 Jahren

Sorry, I thought you’d taken this issue up with Chris. Have you heard back from him?

Rapid account: Devitsu
devitsu Commented vor 10 Jahren

Ugh, sorry about the formatting, I tried to fix it but it won’t let me edit.

Rapid account: Mneticjab
mneticjab Commented vor 10 Jahren

This is Bad. Closing the issue without a solution!

Rapid account: Community
community Commented vor 10 Jahren

Hey Arun, I think I replied to you 4 days ago with the sample .NET code? Did you get it?

Rapid account: Japerk
japerk Commented vor 10 Jahren

No replies for a month, so I’m going to assume devitsu’s solution is correct and/or the issue has been resolved.

Rapid account: Devitsu
devitsu Commented vor 10 Jahren

Hi,

(Hopefully someone else might find this useful)
I had a similar issue with Unirest, the following worked for me:

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();
    }
}```
Rapid account: Mneticjab
mneticjab Commented vor 10 Jahren

Hai Ismaelc,

Thanks for your interest. I will mail you immediately.

Join in the discussion - add comment below:

Login / Signup to post new comments