首页 > 解决方案 > 如何在 api post 命令中传递非英语字符

问题描述

我正在编写一个 powershell 脚本并尝试使用 Azure DevOps api 运行一个 post 命令,但我的一个值包含非英语字符,并且 Invoke-RestMethod 总是失败:{“$id”:“1”,“innerException ":null,"message":"您必须在请求正文中传递有效的补丁文档。","typeName":"Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common"," typeKey":"VssPropertyValidationException","errorCode":0,"eventId":3000} 如果我删除非英语字符,它会按预期工作。

我需要做什么才能让非英语字符在 json 正文中被接受。

标签: powershellazure-devops-rest-api

解决方案


弄清楚了。只需将“;charset=UTF-8”添加到我的内容类型。


推荐阅读