Microsoft Graph API-搜索主题中包含#的电子邮件时,未终止的字符串文字错误 [英] Microsoft Graph API - unterminated string literal Error when searching for emails which contain # in the subject

查看:111
本文介绍了Microsoft Graph API-搜索主题中包含#的电子邮件时,未终止的字符串文字错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在批处理查询中在Office 365上搜索电子邮件时,我收到了未终止的字符串文字错误.仅当主题搜索查询中有#个字符时,才会发生这种情况.

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.

像这样的论坛讨论( https://issues.oasis-open.org/browser/ODATA-1101 )建议我对#符号进行百分比编码,但它给出了相同的错误.

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.

当我将以下请求发布到批处理终结点时( https://graph.microsoft. com/v1.0/ $ batch)

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)\""
    }]
}

我收到此错误

{
  "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?

谢谢, 灰烬

推荐答案

#字符用于分隔

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.

您的问题很可能是一种编码-根据您对查询字符串的编码方式,#可能会单独留下,而实际上您希望将其编码为%23.

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.

这篇关于Microsoft Graph API-搜索主题中包含#的电子邮件时,未终止的字符串文字错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆