[R] Request body format is wrong. Make sure the json request is serialized correctly and there are no null members"- Text Mining With Cognitive API

Shivi Bhatia shivipmp82 at gmail.com
Fri Jan 27 13:22:26 CET 2017


Hi Team,

I am building a sentiment and text mining model with R and Cognitive API. I
am getting the error as mentioned in the subject:

Request body format is wrong. Make sure the json request is serialized
correctly and there are no null members. Can you please advice what is
incorrect i am doing in the code below:

modi_df["language"] = "en"
modi_df["id"] = seq.int(nrow(modi_df))
request_body_modi = modi_df[c(2,3,1)]

# Converting tweets dataframe into JSON
request_body_json_modi = toJSON(list(documents = request_body_modi))
# Calling text analytics API


result_modi = POST("
https://westus.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment",
                    body = request_body_json_modi,
                    add_headers(.headers =
c("Content-Type"="application/json","Ocp-Apim-Subscription-Key"="bc8c8427fd74412ea51967373e418681")))

Output = content(result_modi)
Thank You!.

	[[alternative HTML version deleted]]



More information about the R-help mailing list