Set and Get custom HTTP Header
This blog is to illustrate following solution which might be helpful in certain scenario:
1. Set Custom HTTP Header in sapui5
2. Get Custom HTTP Header in Gateway
So Let’s start !
1. How to set custom HTTP Header in sapui5
This is simple and can be achieved by setHeaders method of either sap.ui.model.odata.v2.ODataModel or sap.ui.model.odata.ODataModel.
Able to see customer header sets in F12:
2. How to get custom HTTP Header in GW
Also simple by calling get_dp_facade of interface /iwbep/if_mgw_conv_srv_runtime.
Able to see in GW code runtime:
Now we able to set HTTP custom header in UI5 and get in GW.
This is sometimes helpful when you want to pass additional data from UI to GW but found nowhere to place them.
e.g. When implement get_entity/get_stream method, few places we can put parameters. Then maybe header is a place to consider.
Hope it helps !
Thank You Very Much for this Yis. You just saved me a lot of development time! 🙂
Thanks for the blog, can you please inform how to remove the headers as well?
Thanks in advance.
needed this helped me a lot.
When i add params via fileuploader class, i couldn't get it in create_stream method.
Do you have any solution?
Thanks for this!