15
Views
8
Comments
Solved
Rest API Odata getting 400 Error while in test it is working fine
Application Type
Reactive, Service

Hello i am consuming an Rest API , below is my API , 

https://dev-mobile.xyz.com/sap/opu/odata/sap/abc/SiteEmpSet?$filter=CustCode eq {CustCode} and SiteCode eq {SiteCode} and OfficeCode eq {OfficeCode} and DivisionCode eq {DivisionCode} and SkillCode eq {SkillCode} and EmpNo eq {EmpNo}

This is ODATA , and all query parameters are type interger . 

while test i am putting hradcoded values it is working fine but for dyanamic values it is throwing 400 Error code, 

What is wrong?


Thanks in advance.

2023-02-28 05-45-34
Bharat koshti
Solution

In may case API url is like below.

https://dev-mobile.xyz.com/sap/opu/odata/sap/abc_SRV/SiteEmpSet?$filter=CustCode eq '{CustCode}' and SiteCode eq '{SiteCode}'....

here , OutSystems is treating this  {CustCode} as the FULL value of $filter,which makes fails . so i  Create one input parameter with text datatype and then pass full condition my logic like pass full condition from  logic: "CustCode eq '" + CustCode + "' and SiteCode eq '" + SiteCode + "'...."

and updated my API url like 

...? $filter={FilterText}

and my issue gets resolved with this way. now i got 200 OK .


Thanks for all of you . thanks for your valuable time .


with the above link i got full details of my log and which help me to sortout the issue . 

2026-06-20 17-43-43
Sherif El-Habibi
Champion

Hello,

Did you try comparing the URL before and after using dynamic values? Even a single extra space can cause the API to fail. I suggest checking both versions to see exactly how the request is being sent there might be an unintended space in one of the parameters, such as {SkillCode}. Make sure to trim and remove any extra gaps. 

2023-02-20 05-20-57
Nam Nguyen

Hi,

I think you should check the API request with dynamic values via Integration log in Service Center and compare it with the API request with hardcode values to check malformed syntax.

Cheers,
Nam

2023-02-28 05-45-34
Bharat koshti

i tried to check all details but in integration logs cant find API request. this is what i am getting 

2019-01-07 16-04-16
Siya
 
MVP

@Bharat koshti : Please follow the steps

  1. Service Center -> Your Module -> Integration -> Consumed REST APIs -> Your API - > Logging level = Full
  2. Service Center -> Monitoring -> Integration : Here you will be able to see the full logs.
2023-02-28 05-45-34
Bharat koshti

the above screen shot which i send is from the given location only. i can see only this information.

2019-01-07 16-04-16
Siya
 
MVP

Not sure that's the correct screen short is. Please goto the integration  log like below




2023-02-28 05-45-34
Bharat koshti

Thanks but i have limited stack and details avalaible so i read some documenatation . below is the link for full logs. 

Kilian wrote an quick post on how to enable this: https://www.outsystems.com/forums/discussion/33272/setting-logging-level-of-a-rest-api/ 

which help me to get more details and from this details i get to know root cause . but anyways thanks for your efforts . thank you again. i will explain my root cause n solution for this in next comment. so that other may face issue they will be use this. 

2023-02-28 05-45-34
Bharat koshti
Solution

In may case API url is like below.

https://dev-mobile.xyz.com/sap/opu/odata/sap/abc_SRV/SiteEmpSet?$filter=CustCode eq '{CustCode}' and SiteCode eq '{SiteCode}'....

here , OutSystems is treating this  {CustCode} as the FULL value of $filter,which makes fails . so i  Create one input parameter with text datatype and then pass full condition my logic like pass full condition from  logic: "CustCode eq '" + CustCode + "' and SiteCode eq '" + SiteCode + "'...."

and updated my API url like 

...? $filter={FilterText}

and my issue gets resolved with this way. now i got 200 OK .


Thanks for all of you . thanks for your valuable time .


with the above link i got full details of my log and which help me to sortout the issue . 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.