Soru

Zorluk: ZorCharacteristics of REST-Based APIs (CRUD, HTTP Verbs, Data Formats)

A automated network management script receives an HTTP status code of 415 Unsupported Media Type after issuing a POST request containing a structured JSON body to a REST-based API endpoint on a Cisco controller. Which HTTP request header was missing or misconfigured in the client's request payload headers to cause this failure?

  1. Content-TypeCevap
  2. B
    Accept
  3. C
    Authorization
  4. D
    Host

Cevap

The Content-Type header must be specified in the request to inform the server of the data format (such as application/json) being sent in the body.
The Content-Type request header indicates the media type (such as application/json or application/yang-data+json) of the entity-body sent to the recipient. When a client sends a POST, PUT, or PATCH request containing data but fails to include a supported Content-Type header, the server rejects the request with an HTTP 415 Unsupported Media Type status code.

Adım Adım Çözüm

1
Analyze the HTTP status code returned by the REST API endpoint.
The server returned HTTP status 415 (Unsupported Media Type).
HTTP 415 indicates that the server refuses to service the request because the payload is in a format not supported by the requested resource for the specified method.
2
Differentiate between client payload metadata headers and client expectation response headers.
Content-Type describes the request body format sent to the server, while Accept specifies acceptable response formats returned by the server.
Sending data without a proper Content-Type header prevents the API parser from identifying how to process the request payload.
3
Identify the missing header responsible for media type negotiation on incoming request bodies.
Setting Content-Type to application/json resolves the 415 status error.
The server requires explicit declaration of the data structure (e.g., JSON or XML) contained in the POST request body.

Anahtar Kavram

REST API HTTP Headers and Media Type Negotiation (Content-Type vs. Accept)
Bu soruyu puanla