Forum Discussion

thisIsTrue's avatar
thisIsTrue
Visitor
3 years ago

Is it possible to remove Content-Type in a POST request.

Hello Community.

 

I'm trying to test a REST endpoint where we have a rule that the header "Content-Type" is not mandatory. So I'm setting up some tests for this case, but I can't remove the "Content-Type" header for a POST request.

How do you send a POST request without the header "Content-Type"? (is it even possible to remove)

Thanks in advance. 

  • Hey thisIsTrue 

     

    Yep you can do this - the easy way is to blank out the MediaType dropdown on your request.

     

    The MediaType combo box (combo box = editable dropdown) on your request config is what defines the Content-Type header on your request.  If you have a POST with a json payload, then your MediaType combo box is likely set as 'application/json' (although it could be other values).

     

    If you just delete the value from the MediaType combo box and resubmit your POST, you'll see the Content-Type header is no longer present in the request

     

    Cheers,

     

    Rich

  • richie's avatar
    richie
    Community Hero

    Hey thisIsTrue 

     

    Yep you can do this - the easy way is to blank out the MediaType dropdown on your request.

     

    The MediaType combo box (combo box = editable dropdown) on your request config is what defines the Content-Type header on your request.  If you have a POST with a json payload, then your MediaType combo box is likely set as 'application/json' (although it could be other values).

     

    If you just delete the value from the MediaType combo box and resubmit your POST, you'll see the Content-Type header is no longer present in the request

     

    Cheers,

     

    Rich