Trying to do a post on a graph query in rest assured and couldn't get the query right.
Request:
"{query\":inventoryPositions(productRef:\"SKU_3\"){edges{node{onHand quantities{edges{node{ref quantity type}}}}}}}")
Response:
{
"errors": [
{
"code": "400",
"message": "Could not read document: Unexpected character ('q' (code 113)): was expecting double-quote to start field name\n
}
]
}
I have also tried this but not working:
{"query":"{inventoryPositions(productRef:\"SKU_3\"){edges{node{onHand quantities{edges{node{ref quantity type}}}}}}}"}
Please help.
basically it need 2 escape wherever u post a variable for example
"{\n"
+ "\"query\": \"{inventoryPositions(productRef: \\"SKU_3\\" locationRef: \\"locRef1\\"){edges{node{onHand quantities{edges{node{ref quantity type}}}}}}}\"\n"
+ "}"
worked for me
Related
I'm trying to test the GraphQL server I built, by sending GraphQL queries to the server using Postman.
It works when I'm using raw radio button, but when I'm trying to use GraphQL radio button, it returns "message": "Syntax Error: Expected Name, found String \"query\"".
I have tried to change the syntax: mainly add or delete curly braces but nothing happened.
The query I sent in raw mode (working):
{
person(id:"123456789") {
personal_info {
address
}
}
}
The query I sent in GraphQL mode:
QUERY:
query getPerson ($id: String){
person(id: $id){
personal_info {
address
}
}
}
GRAPHQL VARIABLES:
{
"id": "123456789"
}
I expect to get the data I asked for, but I get the error message:
{
"errors": [
{
"message": "Syntax Error: Expected Name, found String \"query\"",
"locations": [
{
"line": 1,
"column": 2
}
]
}
]
}
I had the same problem. During researching I have found the next answer on stackoverflow, thanks #gbenga_ps.
Resolved by adding the correct header to Postman request:
Body of request should be something like next:
{
courses {
title
}
}
If incorrect content-type set, error like next happened:
{
"errors": [
{
"message": "Syntax Error: Expected Name, found String \"query\"",
"locations": [
{
"line": 1,
"column": 2
}
]
}
]
}
I'm having some trouble figuring out how to use the office365 api to fetch messages given a conversationId.
Let's say my conversationId is AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=
I'll make a request like
https://outlook.office.com/api/v1.0/me/Messages?$filter=ConversationId%20eq%20AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow=
This results in a 400 response like this:
{
"error": {
"code": "RequestBroker-ParseUri",
"message": "Syntax error at position 98 in 'ConversationId eq AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow='."
}
}
I tried other things, such as url encoding the conversationId to AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow%3D which results in the same error.
I also tried simply removing the = which seems to be the character that is freaking it out
https://outlook.office.com/api/v1.0/me/Messages?$filter=ConversationId%20eq%20AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow
but that results in the following error
{
"error": {
"code": "RequestBroker-ParseUri",
"message": "Could not find a property named 'AAQkADlkOGJmMTFmLTc2NjMtMKL3My04ZDhkLTVmZWNjMzA1ODY0NAAQAB11Xh2opSpBiXifMEJjhow' on type 'Microsoft.OutlookServices.Message'."
}
}
I've also tried messing with the url capitalization and using + signs instead of %20 for the filter string, but I consistently get 400 errors back.
I am able to filter by other fields though. For example
https://outlook.office.com/api/v1.0/me/Messages?$filter=IsRead%20eq%20true
returns messages filtered as I would expect.
Any idea what could be going on with the ConversationId filter?
You need to wrap the ConversationId with single quotes.
This is how I forge my request in C#
string finalUrl = "https://outlook.office.com/api/beta/me/Messages?$filter=" + HttpUtility.UrlEncode(string.Format("ConversationId eq '{0}'", conversationId));
I am using Elasticsearch by Restclient in Firefox adds-on
and I have the following problem when updating a document
{
"error": "JsonParseException[Unexpected character (':' (code 58)): was expecting comma to separate OBJECT entries
at [Source: [B#142d626; line: 3, column: 12]]",
"status": 500
}
and i do this
method : post
url: http://localhost:9200/test2/t2/2/_update?pretty
in body
{ "doc" :
"name":"oooooo"
}
any help
thanks
Try with the following JSON in your body:
{
"doc": {
"name": "oooooo"
}
}
In order to do a partial update, the JSON in the body must have a single doc field which contains the fields to update, in this case "name": "oooooo". In your case, you were simply missing the curly braces around the name field.
What's wrong with my request?
I have sting in russian:
$string = Потенциал, %
I want to translate it to ukrainian with google API:
I urlencode string:
$q = urlencode($string)
And i request google API:
https://www.googleapis.com/language/translate/v2?q=%D0%9F%D0%BE%D1%82%D0%B5%D0%BD%D1%86%D0%B8%D0%B0%D0%BB%2C%20%25&target=ua&source=ru&key=A...
In response I get :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
What's wrong with my request?
Solution was simple. Google has UK letters for ukrainian instead of UA.
The target should be uk not ua.I think it will resolve the issue.
In my case I was trying to translate to "es-uy" but despite being a valid language code, Google doesn't support it.
Here are the language codes that the API supports:
https://cloud.google.com/translate/docs/languages
I got this error from my jquery ajax request. ERROR 200 Unexpected token
Here is my JSON :
{
"data": [
{
"answer": "sofo",
"email": "jk#gmail.com",
"secretquestion": "bestfriend"
}
],
"status": 1,
"message": "Success!"
}
I validated on JSONLint and i got Unexpected token. I cant understand my fault. Do u have any ideas?
Thank you
The JSON is valid. There may be a difference in the token name (a spelling mistake?) when you are deserializing it.