Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IMAGE URL
#5
(Nov-30-2021, 01:47 PM)snippsat Wrote:
(Nov-30-2021, 12:59 PM)satyanarayana Wrote: create http url and post to rest api
Have to look at doc for API to see what's required for image upload.
Can use Requests for this.
Example.
import requests

url = 'Api url'
files = {'media': open('D:/Satya_Projects_Onedrive/Epigon_Projects/BILVA_Projects/waveform.png', 'rb')}
requests.post(url, files=files)
Api may need more information like eg API key.
import requests
 
url = 'Api url'
headers = {
    'content-type': "multipart/form-data",
    'accept': "application/json",
    'apikey': "my_key"
    }
files = {'media': open('D:/Satya_Projects_Onedrive/Epigon_Projects/BILVA_Projects/waveform.png', 'rb')}
response = requests.post(url, headers=headers, files=files)

when i run this code I am getting error media is non type error
Reply


Messages In This Thread
IMAGE URL - by satyanarayana - Nov-30-2021, 11:43 AM
RE: IMAGE URL - by snippsat - Nov-30-2021, 12:52 PM
RE: IMAGE URL - by satyanarayana - Nov-30-2021, 12:59 PM
RE: IMAGE URL - by snippsat - Nov-30-2021, 01:47 PM
RE: IMAGE URL - by satyanarayana - Dec-01-2021, 05:35 AM
RE: IMAGE URL - by snippsat - Dec-01-2021, 02:15 PM
RE: IMAGE URL - by DeaD_EyE - Dec-03-2021, 09:10 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020