apache / apache/pulsar

create function with restful API,which has the error "415 Unsupported Media Type"

Open
#16,631 4 comments 0 reactions 0 assignees View on GitHub
Stale
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

Hello, I met an error which needs help. I am looking forward someone can answer it, thank you.
I create function which string like
`{"runtimeFlags":"","tenant":"public","namespace":"default","name":"PublishFunction","className":"org.apache.pulsar.functions.api.examples.PublishFunction","inputs":["persistent://public/default/function-input-topic"],"customSerdeInputs":{},"topicsPattern":"","customSchemaInputs":{},"customSchemaOutputs":{},"inputSpecs":{"persistent://public/default/function-input-topic":{"schemaType":"","serdeClassName":"","schemaProperties":{},"consumerProperties":{},"receiverQueueSize":0,"cryptoConfig":{},"poolMessages":true,"regexPattern":true}},"output":"persistent://public/default/function-output-topic","producerConfig":{"maxPendingMessages":0,"maxPendingMessagesAcrossPartitions":0,"useThreadLocalProducers":true,"cryptoConfig":{},"batchBuilder":""},"outputSchemaType":"","outputSerdeClassName":"","logTopic":"","processingGuarantees":"ATLEAST_ONCE","retainOrdering":true,"retainKeyOrdering":true,"batchBuilder":"","forwardSourceMessageProperty":true,"userConfig":{},"secrets":{},"runtime":"JAVA","autoAck":true,"maxMessageRetries":0,"deadLetterTopic ":"","subName ":"","parallelism ":2,"resources ":{"cpu ":1.0,"ram ":1073741824,"disk ":10737418240},"fqfn ":"","windowConfig ":{},"timeoutMs ":0,"jar ":"/opt/cloud/GEMASPulsar/apache-pulsar-2.10.0/examples/api-examples.jar","py ":"","go ":"","cleanupSubscription ":true,"customRuntimeOptions ":"","maxPendingAsyncRequests ":0,"exposePulsarAdminClientEnabled ":true,"subscriptionPosition ":"Latest "}`, I also try make above string as a json file, but it doesn't work; Then I set Content-Type as application/json or "multipart/form-data".

the detail error is bellow:
`Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 10.172.167.163:8080...
* Connected to 10.172.167.163 (10.172.167.163) port 8080 (#0)
> POST /admin/v3/functions/public/default/PublishFunction HTTP/1.1
> Host: 10.172.167.163:8080
> User-Agent: curl/7.69.1
> Accept: */*
> Content-Type: application/json;charset=utf-8
> Content-Length: 1447
>
* upload completely sent off: 1447 out of 1447 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 415 Unsupported Media Type
< Date: Sat, 16 Jul 2022 11:05:25 GMT
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Type: text/html;charset=iso-8859-1
< Server: Jetty(9.4.43.v20210629)
< Content-Length: 579
<

Error 415 Unsupported Media Type

HTTP ERROR 415 Unsupported Media Type

URI:/admin/v3/functions/public/default/PublishFunction
STATUS:415
MESSAGE:Unsupported Media Type
SERVLET:org.glassfish.jersey.servlet.ServletContainer-70a24463


Powered by Jetty:// 9.4.43.v20210629

`

Contributor guide

Open the contributing guide

Research direction

Reproduce the POST to /admin/v3/functions/public/default/PublishFunction using the supplied function definition and curl request. Start by checking the REST endpoint's accepted request formats and compare application/json with multipart/form-data. Done means determining the supported media type and either correcting the request guidance or confirming a server-side handling defect.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.