You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/16 11:22:38 UTC

[GitHub] [pulsar] Kelly-ZH opened a new issue, #16631: create function with restful API,which has the error "415 Unsupported Media Type"

Kelly-ZH opened a new issue, #16631:
URL: https://github.com/apache/pulsar/issues/16631

   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
   < 
   <html>
   <head>
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
   <title>Error 415 Unsupported Media Type</title>
   </head>
   <body><h2>HTTP ERROR 415 Unsupported Media Type</h2>
   <table>
   <tr><th>URI:</th><td>/admin/v3/functions/public/default/PublishFunction</td></tr>
   <tr><th>STATUS:</th><td>415</td></tr>
   <tr><th>MESSAGE:</th><td>Unsupported Media Type</td></tr>
   <tr><th>SERVLET:</th><td>org.glassfish.jersey.servlet.ServletContainer-70a24463</td></tr>
   </table>
   <hr><a href="https://eclipse.org/jetty">Powered by Jetty:// 9.4.43.v20210629</a><hr/>
   
   </body>
   </html>
   `
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] Kelly-ZH commented on issue #16631: create function with restful API,which has the error "415 Unsupported Media Type"

Posted by GitBox <gi...@apache.org>.
Kelly-ZH commented on issue #16631:
URL: https://github.com/apache/pulsar/issues/16631#issuecomment-1186680416

   Hello,  someone can help me to solve the problem?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] github-actions[bot] commented on issue #16631: create function with restful API,which has the error "415 Unsupported Media Type"

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #16631:
URL: https://github.com/apache/pulsar/issues/16631#issuecomment-1287584744

   The issue had no activity for 30 days, mark with Stale label.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] github-actions[bot] commented on issue #16631: create function with restful API,which has the error "415 Unsupported Media Type"

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #16631:
URL: https://github.com/apache/pulsar/issues/16631#issuecomment-1217382716

   The issue had no activity for 30 days, mark with Stale label.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] kingdom998 commented on issue #16631: create function with restful API,which has the error "415 Unsupported Media Type"

Posted by GitBox <gi...@apache.org>.
kingdom998 commented on issue #16631:
URL: https://github.com/apache/pulsar/issues/16631#issuecomment-1251762501

   > Hello, someone can help me to solve the problem?
   
   you can use curl like below 
   ```
   curl --location --request POST 'http://127.0.0.1:8080/admin/v3/functions/sample/ns1/toupper' \
   --header 'Content-Disposition;' \
   --form 'data=@"/Users/zy/01_prj/pulsar/func/uppercase.py"' \
   --form 'functionConfig=@"/Users/zy/01_prj/pulsar/func/upper.json"'
   ```
   
   or python script below
   
   ```
   import requests
   
   url = "http://127.0.0.1:8080/admin/v3/functions/sample/ns1/toupper"
   
   payload={}
   files=[
     ('data',('uppercase.py',open('/Users/zy/01_prj/pulsar/func/uppercase.py','rb'),'application/octet-stream')),
     ('functionConfig',('upper.json',open('/Users/zy/01_prj/pulsar/func/upper.json','rb'),'application/json'))
   ]
   headers = {
     'Content-Disposition': ''
   }
   
   response = requests.request("POST", url, headers=headers, data=payload, files=files)
   
   print(response.text)
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org