Home > other >  How to send pictures directly to the API file
How to send pictures directly to the API file

Time:03-26



Submit can get the result directly with POSTMAN,

I send the request with the following code, it prompts the data format error, can't figure out the image file should follow the way to write what?

 
Url=""
Files={' images' : (' 1. PNG ', open (' 1. PNG ', 'rb'), 'image/PNG, {})}
Res=requests. Request (" POST ", urls, files, headers=headers)
Print (res) text)

CodePudding user response:

Interfaces to write very simple:

Set the content-type Header to: application/octet stream -
Set the Body, & lt; Image file>

So don't know how to deal with the body for the image file

  • Related