Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Networking UnityWebRequest Post Error

Discussion in '5.4 Beta' started by bdovaz, Dec 25, 2015.

  1. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042
    Making a "POST" with an empty "Dictionary<string, string>" raises the following error:

    "ArgumentException: Cannot create a data handler without payload data"
     
  2. Justinas

    Justinas

    Unity Technologies

    Joined:
    Sep 25, 2013
    Posts:
    12
    Can you describe a scenario where POST without payload data would be meaningful?

    Cheers!
     
  3. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,042
    There are official (example: some social networks) REST APIs that have endpoints to make POST requests with no form data passing.
     
    MV10 likes this.
  4. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    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.