Search code examples
odatasapui5

Why Odata batch service call is not working from local webide?


Hi I am calling the OData batch service as follows

"models": {
    "yourModel": {
        "dataSource" : "yourDataSource",
        "settings" : {
          "useBatch" : true
        }
    }
}

the service call is worked one day before and then later it's not working from local webide. but after deploying the application it is working fine dev system.

In the above code if I use

"settings" : {
              "useBatch" : false
            }

The service is working fine from even local webide.

But I need to call as batch, because if I call as batch only I am able to get Custom message from header like

oResponse.headers.message

How to solve this issue, please help me Thanks in advance.


Solution

  • Please pass headers to your OData Model as below,

                "settings": {
                    "headers": {
                        "X-Requested-With": "XMLHttpRequest",
                        "Content-Type": "application/atom+xml",
                        "DataServiceVersion": "2.0",
                        "X-CSRF-Token": "Fetch"
                    }
                }
    

    This will work and you will get the custom header messages from the back-end OData Service