apoc.load.jsonParams as POST 带有正文输入参数的请求

apoc.load.jsonParams as POST request with Body input parameters

apoc.load.jsonParams 的 Neo4j 文档中有一个如何发出 POST 请求的示例:

CALL apoc.load.jsonParams(
  "https://neo4j.com/docs/search/",
  {method: "POST"},
  apoc.convert.toJson({query: "subquery", version: "4.0"})
);

但不幸的是,这对我来说还不够,因为我还需要一个带有 POST 请求参数的正文:

[HttpPost("getJson")]
[Produces("application/json")]
public async Task<JsonResult> GetJson(int id, [FromBody] List<string> params)

我的尝试:

CALL apoc.load.jsonParams("http://192.168.1.128:4040/api/getJson?id=17",{method: "POST"}, "$.BusinessData[*]") YIELD value WITH ["DATA1", "DATA2"] as body return *

错误信息:

Failed to invoke procedure `apoc.load.jsonParams`: Caused by: java.lang.RuntimeException: Can't read url or key http://192.168.1.128:4040/api/getJson?id=17 as json: Server returned HTTP response code: 500 for URL

那么 apoc 调用看起来如何才能满足 POST 请求?

来自 apoc.load.jsonParams 文档:

apoc.load.jsonParams(urlOrKey :: STRING?, headers :: MAP?, payload :: STRING?, path = :: STRING?, config = {} :: MAP?) :: (value :: MAP?)

将body作为有效负载参数传输,并用apoc.convert.toJson将其转换为Json字符串列表。还需要将 Content-Type 定义为 header 中的 application/json。 (不要忽略反引号)

CALL apoc.load.jsonParams("http://192.168.1.128:4040/api/getJson?id=17", 
{`Content-Type`:"application/json"}, apoc.convert.toJson(["DATA1", "DATA2"]), "$.BusinessData[*]") YIELD value as item