Closed p-eye closed 2 months ago
i solved it. To request with "application/x-www-form-urlencoded", map objectNode to String. thank you
DataStream<String> processedStream = kafkaStream.map(new MapFunction<ObjectNode, String>() {
@Override
public String map(ObjectNode objectNode) throws Exception {
JsonNode valueNode = objectNode.path("value");
StringBuilder result = new StringBuilder();
boolean first = true;
Iterator<Map.Entry<String, JsonNode>> fields = valueNode.fields();
while (fields.hasNext()) {
if (first)
first = false;
else
result.append("&");
Map.Entry<String, JsonNode> entry = fields.next();
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(entry.getValue().asText(), "UTF-8"));
}
return result.toString();
}
});
Hello, I want to send a POST request with data containing a jsonObject Array. Here is an example of the data. The depth of the object is dynamically changeable
For this, I mapped the row to the AppLog class and created an httpSink.
This is my problem. When I send a POST request above httpSink, the request type maybe not the same as the receiving side. this is an Postman case, the "x-www-form-urlencoded" format sends correct requests, but sending it in "form-data" format causes a mismatch with the receiving side. This "form-data of Postman" problem is the same as the one with the flink-http-connector.
So, I tried some cases in the flink-http-connector to post with application/x-www-form-urlencoded but couldn't solve it.
Is there are any options to solve?
thank you