在石英调度程序中发送 json 负载时出错

Getting an error while sending a json payload in quartz scheduler

我正在尝试在 quartz 调度程序中发送 json 负载。我将 header 设置为 Content-type:application/json,但由于某种原因,我的 json 字符串抛出错误:未捕获的错误,json 中的意外标记。

我发送到 graphql 服务的原始 json 如下所示:

  {
    GetAllAuthors{
      id
      name
    }
   }

但是为了让它在 quartz 中工作,我需要模仿一个 rest API 调用,这就是我尝试使用以下内容的原因:

   { "query":{{""{\nGetAllAuthors {\nid\nname\n}\n\n}""}} }

以上也给我 "Uncaught error, unexpected token in json" 错误。有什么我遗漏或忽略的吗?

PS:我尝试使用在线 json 格式化程序,当我尝试验证上述 json 时,出现以下错误:

     Error: Parse error on line 2:
      { "query": {      {           "" {\               nGetA
        --------------^
        Expecting 'STRING', '}', got '{'

那是无效的 Json。如果是:

 {
    "GetAllAuthors": [
        "id",
        "name"
    ]
 }

但我怀疑您正在尝试这样的事情:

 {
    "GetAllAuthors": {
        "id": 123,
        "name": "James Brown"
    }
 }

在这里玩,直到你做对为止:https://jsonlint.com/

编辑:我没有使用过 GraphQL,但此页面显示了(非 JSON)GraphQL 查询如何通过使用查询字符串的 POSTing JSON 或 GETting 通过 Http 传输:https://graphql.org/learn/serving-over-http/

我通过 Mozilla 的网络选项卡进行测试发现了这一点 - 正确的格式是:

{"query":"{\n GetAllAuthors{\n id\n name\n}\n}\n","variables":null, "operationName":空}