You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure API管理中GraphQL POST触发器Resolver配置异常排查

Azure API管理GraphQL Mutation的POST请求Resolver Policy问题

我在Azure API管理服务中配置首个GraphQL Mutation时遇到了问题。之前用GET方式配置这个Mutation可以正常运行,但业务要求必须使用POST请求,切换后执行时Azure返回错误提示(见截图)。

完整GraphQL Schema

schema {
  query: ChatMessageQueries
  mutation: ChatMessageMutations
}

scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")

 type ChatMessageMutations {
  SendChatTextMessage(input: SendChatTextMessageInput!): SendChatMessageResp
}

input SendChatTextMessageInput {
  messageId: UUID!
  senderUserId: UUID!
  receiverUserId: UUID!
  messageContent: String!
}

enum ChatMessageSendStatus {
  SUCCESS
  FAIL
}

 type ChatMessageErrorData {
  code: Int
  message: String
}

 type SendChatMessageResp {
  messageId: UUID!
  status: ChatMessageSendStatus!
  error: ChatMessageErrorData
}

 type ChatTextMessage {
  messageId: UUID!
  senderUserId: UUID!
  receiverUserId: UUID!
  messageContent: String!
}

 type ChatMessageQueries {
  GetUserChatMessages(userId: UUID!): [ChatTextMessage]
}

当前配置的Resolver Policy代码

<http-data-source>
    <http-request>
      <set-method>POST</set-method>
      <set-url>[URL]</set-url>
      <set-header name="Content-Type" exists-action="override">
        <value>application/json</value>
      </set-header>
      <set-body>@{
        var args = context.Request.Body.As<JObject>(true)["arguments"];  
        JObject jsonObject = new JObject();
        jsonObject.Add("messageId", args["messageId"]);
        jsonObject.Add("senderUserId", args["senderUserId"]);
        jsonObject.Add("receiverUserId", args["receiverUserId"]);
        jsonObject.Add("messageContent", args["messageContent"]);
        return jsonObject.ToString();
      }</set-body>
    </http-request>
  </http-data-source>

请问我的Resolver Policy存在什么问题?


内容的提问来源于stack exchange,提问作者Freddy Martinez Garcia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 21:28:33