问题
When i am searching for emails on office 365 in a batch query, i am getting a unterminated string literal error. This is happening only when i have a # character in the subject search query.
Forum discussions like this (https://issues.oasis-open.org/browse/ODATA-1101) have suggested me to percentage encode the # symbol but it gave the same error.
When I am POSTing the below request to the batch endpoint(https://graph.microsoft.com/v1.0/$batch)
{
"requests": [{
"id": 1,
"method": "GET",
"url": "/users/somemailbox@mytenant.onmicrosoft.com/messages?$select=id,internetMessageId,toRecipients,ccRecipients,bccRecipients,subject,isRead,sender,receivedDateTime&$top=500&$search=\"received>=2019-06-19 AND (subject:\\\"PO# 123\\\" AND from:email@domain.com)\""
}]
}
I get this error
{
"responses": [
{
"id": "1",
"status": 400,
"body": {
"error": {
"code": "BadRequest",
"message": "There is an unterminated string literal at position 39 in '\"received>=2019-06-19 AND (subject:\\\"PO'.",
"innerError": {
"request-id": "801078a5-d3c6-4b93-a152-6653a3d8ca44",
"date": "2019-07-22T06:29:16"
}
}
}
}
]
}
Can you guys please help me with fixing my search query?
Thanks, Ashish
回答1:
The #
character is used to delimit fragments in a URL, which are intended to represent client side state. Browsers will generally not send the #
or anything following it, and servers will generally ignore it if it's sent accidently.
Your issue is most likely an encoding one - depending on how you're encoding the query string the #
might be getting left alone, when in actuality you want it to be encoded to %23
.
来源:https://stackoverflow.com/questions/57140375/microsoft-graph-api-unterminated-string-literal-error-when-searching-for-email