如何使用处理器 invokeHTTP 在 nifi 中 运行 POST 带有参数的 http 请求
how to run a POST http request with parameter in nifi using processor invokeHTTP
我在互联网上搜索了很多,但没有找到适合我的问题的答案。
我有一个看起来像这样的 curl 命令:
curl -X POST --data-binary 'query=select ?s ?p ?o where {?s ?p ?o} limit 10' https://your-neptune-endpoint:port/sparql
我想知道我可以在 invokeHTTP 处理器中的哪个字段中添加查询参数及其值,因为我尝试了很多方法但都是徒劳的
我的方法之一是创建一个包含以下内容的 generateFlowFile :
query=select ?s ?p ?o where {?s ?p ?o} limit 10'
并且输出被重定向到一个 invokehttp 处理器,但我得到了这个错误
invokehttp.response.body
{"detailedMessage":"Missing 'query' or 'update' parameter for POST request","code":"MissingParameterException","requestId":"64bf26c2-31ab-1ee2-df39-793e0abb0d0e"}
有什么想法吗?
所以你有这个 http 请求:
> POST /sparql HTTP/1.1
> User-Agent: curl/7.38.0
> Host: your-neptune-endpoint:8182
> Accept: */*
> Content-Length: 47
> Content-Type: application/x-www-form-urlencoded
您必须至少为 InvokeHttp nifi 设置以下参数:
HTTP Method: POST
Remote URL: https://your-neptune-endpoint:8182/sparql
SSL Context Service: <...>
Content-Type: application/x-www-form-urlencoded
Content-Type=application/x-www-form-urlencoded
声明参数将以 a=v1 & b=v2 &...
格式传递
可以在 InvokeHttp 之前使用 GenerateFlowFile 设置流文件主体
query=select ?s ?p ?o where {?s ?p ?o} limit 10
note the unnecessary quote in body in your question
如果您的参数值包含一些特殊字符,如 =
或 &
,最好在 GenerateFlowFile 中对其进行编码:
query=${'select ?s ?p ?o where {?s ?p ?o} limit 10':urlEncode()}
我在互联网上搜索了很多,但没有找到适合我的问题的答案。
我有一个看起来像这样的 curl 命令:
curl -X POST --data-binary 'query=select ?s ?p ?o where {?s ?p ?o} limit 10' https://your-neptune-endpoint:port/sparql
我想知道我可以在 invokeHTTP 处理器中的哪个字段中添加查询参数及其值,因为我尝试了很多方法但都是徒劳的
我的方法之一是创建一个包含以下内容的 generateFlowFile :
query=select ?s ?p ?o where {?s ?p ?o} limit 10'
并且输出被重定向到一个 invokehttp 处理器,但我得到了这个错误
invokehttp.response.body
{"detailedMessage":"Missing 'query' or 'update' parameter for POST request","code":"MissingParameterException","requestId":"64bf26c2-31ab-1ee2-df39-793e0abb0d0e"}
有什么想法吗?
所以你有这个 http 请求:
> POST /sparql HTTP/1.1
> User-Agent: curl/7.38.0
> Host: your-neptune-endpoint:8182
> Accept: */*
> Content-Length: 47
> Content-Type: application/x-www-form-urlencoded
您必须至少为 InvokeHttp nifi 设置以下参数:
HTTP Method: POST
Remote URL: https://your-neptune-endpoint:8182/sparql
SSL Context Service: <...>
Content-Type: application/x-www-form-urlencoded
Content-Type=application/x-www-form-urlencoded
声明参数将以 a=v1 & b=v2 &...
可以在 InvokeHttp 之前使用 GenerateFlowFile 设置流文件主体
query=select ?s ?p ?o where {?s ?p ?o} limit 10
note the unnecessary quote in body in your question
如果您的参数值包含一些特殊字符,如 =
或 &
,最好在 GenerateFlowFile 中对其进行编码:
query=${'select ?s ?p ?o where {?s ?p ?o} limit 10':urlEncode()}