Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

OData $batch GET operation with datetime value shows error "Invalid URI Segment"

0 Kudos
1,331
  • SAP Managed Tags:

This is my $batch GET operation with parameters. As you can see the date parameter "PostDate" is filled with datetime value as datetime'2022-01-31T12:12:55'.
--batch

Content-Type: application/http
Content-Transfer-Encoding: binary

GET PostHeadSet(PostDate=datetime'2022-01-31T12:12:55' ,ContractID='TFS_I19_1234561' ,ContractCat='1' ,LegalEntity='TFS_I19' ,AccSystem='S_IFRS9' )?$expand=ItemsNav HTTP/1.1


--batch

--batch--

The response shows error "Invalid URI Segment"

In debugging, at the following method /IWCOR/CL_DS_PROC_DISPATCHER->PARSE_BATCH_REQUEST, line 143, the value for URI gets truncated for the datetime value, which is causing this issue. Any idea how to pass this datetime value so that this URI accepts the value in proper format?

Thanks, Shyam

2 REPLIES 2

bbotelho2014_94
Newcomer
879
  • SAP Managed Tags:

For anyone currently having this issue, I was able to solve it with the use of encodeURIComponent. Check the example below:

var sPath = "/TestDateSet(Test='" + sTest + "',Testdat=datetime'" + encodeURIComponent((sDate + "T00:00:00")) + "'";

_oODataModel.read(sPath, { success: fSuccess, error: fError });


Make sure that sDate has the format yyyy-MM-dd in this case I'm not using an actually DateTime value that's why I'm passing "T00:00:00" in front of sDate, just make sure your DateTime value follows this format yyyy-MM-ddTHH:mm:ss and it should work.

0 Kudos
879
  • SAP Managed Tags:

I faced the exact same issue with datetime in batch. Thank you for your post