当我在图形探索者中搜索包含特殊字符的用户时,通过:
https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'jörg')
这样做很好,我得到了一个适当的结果集,如:
{
...
"displayName": "Jörg XYZ",
"givenName": "Jörg",
...
},
现在,在我的node.js
项目中,我尝试通过以下方法对axios
进行同样的处理:
axios.default.get('https://graph.microsoft.com/v1.0//users?$filter=startswith(displayName,\'jö\')')
但是我得到了一个空的结果集。
因此,我将j改为joe:
axios.default.get('https://graph.microsoft.com/v1.0//users?$filter=startswith(displayName,\'joe\')')
我只知道用户的名字中有,Joe,。但我需要J。这是怎么回事?
我已经试过通过:
const options = {
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json;charset=ISO-8859-1'
}
};
但没有成功。我还能试试看什么?
发布于 2021-11-25 12:17:42
最后这件事很简单。我错过的唯一一件事是在查询被触发之前对名称执行编码:
let nameEncoded = encodeURI(name);
axios.default.get(`https://graph.microsoft.com/v1.0//users?$filter=startswith(displayName,'${nameEncoded}')`)
https://stackoverflow.com/questions/70109414
复制相似问题