HTTP/1.1 415 Unsupported Media Type

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
Paul C
Posts: 15
Joined: Fri Nov 25, 2022 6:38 am

HTTP/1.1 415 Unsupported Media Type

Post by Paul C »

what does this mean in my Diagnostic log?
HTTP/1.1 415 Unsupported Media Type

Thanks
Paul
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Scott Klement »

The HTTP server only accepts data in certain formats. It's sending you "415 Unsupported Media Type" to tell you that it doesn't understand the format you've selected.

Typically if you send JSON, the media type should be "application/json". If XML, sometimes they accept "text/xml" but the standard is really "application/xml". But it all really depends on the specs for the API you're calling.
Paul C
Posts: 15
Joined: Fri Nov 25, 2022 6:38 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Paul C »

Thanks for the info. I think I see where the problem may be. so, I corrected where I have "application/json/" to "application/json" (without the "/" at the end. and now I am getting this error. What does this mean?

SetError() #13: HTTP/1.1 400 Bad Request
recvresp(): end with 400
recvdoc parms: identity 95
header_load_cookies() entered
recvdoc(): entered
SetError() #0:
recvdoc(): Receiving 95 bytes.
{
"error": {
"message": "Object reference not set to an instance of an object."
}
}
SetError() #13: HTTP/1.1 400 Bad Request
http_close(): entered
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Scott Klement »

Now it sounds like something is wrong with the JSON you are sending. It says it has an object reference that isn't pointing to an object.
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Scott Klement »

Actually... thinking about it a little bit more... this sounds more like a Java error than a JSON one. Perhaps the server is having some problems, too?
Paul C
Posts: 15
Joined: Fri Nov 25, 2022 6:38 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Paul C »

do you mean our AS400 might not have the latest JAVA version? thanks
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Scott Klement »

Aren't you writing your program in RPG? Why would it matter what version of Java you have?!?!
Paul C
Posts: 15
Joined: Fri Nov 25, 2022 6:38 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Paul C »

yes, it is written in RPG. It is the question you mentioned with JAVA error and server error? would this be an error on our AS400 or the other server that we are trying to connect to?
Scott Klement
Site Admin
Posts: 636
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP/1.1 415 Unsupported Media Type

Post by Scott Klement »

RPG programs cannot produce Java errors.

My guess is that the HTTP server you are connecting to is using Java, and it has a bad reference to a Java object in it's code.
Post Reply