Topic
  • 5 replies
  • Latest Post - ‏2013-09-11T16:17:59Z by d.m.spice
nepomuk
nepomuk
125 Posts

Pinned topic REST POST with no payload

‏2013-09-11T10:51:19Z |

Is it possible to process a POST url with no payload (message body) ? Datapower seems to assume that there is a message body, tries to parse it and fails.

Guy

  • kenhygh
    kenhygh
    1577 Posts

    Re: REST POST with no payload

    ‏2013-09-11T12:52:43Z  

    Guy,

    Go in to the Objects->Services-> MPGW -> your mpgw, and turn on 'Process Messages Whose Body Is Empty'

  • d.m.spice
    d.m.spice
    61 Posts

    Re: REST POST with no payload

    ‏2013-09-11T14:27:23Z  

    Out of curiosity, why would you send an empty payload to a POST?  The purpose of a REST POST is to post a resource to the server.  Is the contents of what you are posting all in post parameters?

  • nepomuk
    nepomuk
    125 Posts

    Re: REST POST with no payload

    ‏2013-09-11T16:01:40Z  
    • kenhygh
    • ‏2013-09-11T12:52:43Z

    Guy,

    Go in to the Objects->Services-> MPGW -> your mpgw, and turn on 'Process Messages Whose Body Is Empty'

    That is already turned on to force rhe rule to be executed for GETs

  • nepomuk
    nepomuk
    125 Posts

    Re: REST POST with no payload

    ‏2013-09-11T16:05:16Z  
    • d.m.spice
    • ‏2013-09-11T14:27:23Z

    Out of curiosity, why would you send an empty payload to a POST?  The purpose of a REST POST is to post a resource to the server.  Is the contents of what you are posting all in post parameters?

    The designers have decided to put all the data needed in the URL, they now want to make it a PUT. The only way I can make a POST or PUT work with no message body is to set the request type to non-xml. I tried a PUT and datapower first complained that Content-Length was invalid, so I added Content-Length:0 and then it tried to parse non existant content.

  • d.m.spice
    d.m.spice
    61 Posts

    Re: REST POST with no payload

    ‏2013-09-11T16:17:59Z  
    • nepomuk
    • ‏2013-09-11T16:05:16Z

    The designers have decided to put all the data needed in the URL, they now want to make it a PUT. The only way I can make a POST or PUT work with no message body is to set the request type to non-xml. I tried a PUT and datapower first complained that Content-Length was invalid, so I added Content-Length:0 and then it tried to parse non existant content.

    Oh ok, seems like poor design to have everything in the URL, but that's just me :)  

    We have a generic MPG for all of our REST calls that accommodates empty and non-empty payloads.  You may also need to turn "Non-XML Processing" on for the rules in the policy.

    Also, this may be of some help - it aided us a while back - http://www-01.ibm.com/support/docview.wss?uid=swg21566838