UnityWebRequest Post Error

Making a "POST" with an empty "Dictionary" raises the following error:

"ArgumentException: Cannot create a data handler without payload data"

Can you describe a scenario where POST without payload data would be meaningful?

Cheers!

There are official (example: some social networks) REST APIs that have endpoints to make POST requests with no form data passing.

1 Like

I just ran into this bug (along with a handful of other problems, here and here). It is completely normal in pure REST APIs to either pass parameters in header values and/or in the URI.

And it is a bug if you want to do HTTP correctly. The HTTP method (GET, POST, etc) is merely an indicator of the type of action being requested. In any clean implementation of the HTTP specification (virtually required to correctly implement Dr. Fielding’s REST concept; see especially chapters 5 & 6), GETs are idempotent resource requests, all other HTTP methods are for applying changes to resources.

The HTTP specification never requires payload body (“entity”) under any circumstances. In fact, the spec clearly states: “Request and Response messages MAY transfer an entity if not otherwise restricted by the request method or response status code” and in IETF-speak, “MAY” means it’s optional.

The association of POSTs with “form data” is an HTML convention, it has absolutely nothing to do with the HTTP specification. HTML is just another content-type for resource representation and has no particular significance to HTTP.