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/09/20 02:31:30 UTC

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

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