HTTP request 415 error-unsupported media type (unsupported media type)

Source: Internet
Author: User
Tags unsupported

HTTP request 415 error-unsupported media type (unsupported media type)

There are usually the following situations:

1: Check your HTTP request header information. For example, the User-Agent is set by the server to reject the request;

For example, the crawler you write may be rejected because it is not disguised as a browser.

User-Agent details

2: view your HTTP Request Method and server-side settings

For example, there is an interface that forces post requests. Are you using a non-POST request?

3: POST request parameter settings. required in JSON format

For example, the following two sections of code,

The following JSON parameter, body

 

import requestsimport jsonpayload={"userName":"names","userCode":"123456","phoneNum":"7800","regPic":"picData"}headers={‘content-type‘: ‘application/json‘}burl="http://httpbin.org/post"r=requests.post(burl, data=json.dumps(payload), headers=headers)print r.text

 

The following form format parameters

import requestsimport jsonpayload={"userName":"names","userCode":"123456","phoneNum":"7800","regPic":"picData"}headers={‘content-type‘: ‘application/json‘}burl="http://httpbin.org/post"r=requests.post(burl, data=payload, headers=headers)print r.text

HTTP request 415 error-unsupported media type (unsupported media type)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.