47
Views
3
Comments
Solved
REST API returns results as expected, but PWA testing returns Error 400: Bad Request
Question
Service Studio Version
11.53.27 (Build 61662)
Platform Version
11.18.0 (Build 37468)

Hi All,

I have a rest API method that should filter a Player based on the GroupId they are against on SharePoint.

Here is the Get REST API URL I am using: "_api/web/lists/getbytitle('Player Information')/items?$filter=(Part_x0020_of_x0020_GroupsId eq '{GroupId}') "

It should be noted that this works just fine in the REST API window when I test it. All the credentials work, not errors there, I've even had to force break it in the REST API window to see if errors come back as they should, and they do, so from the actual setup of the API call, I can't see any reason it's 'broken here'.. I get my Status 200: Okay and all the information, correctly filtered, as I'm expecting..

The issue arises when I test via the PWA. I have several other calls on the app, to the same SharePoint using the same credentials. I even reference a few separate lists, and they all work fine too. It just seems using the $filter= query in the API is breaking it when testing in PWA for some reason.

I've checked the input for the 'GroupId' is being passed to the page correctly, and it is, so I'm really confused why it works in the REST API window/ setup, but not in PWA. The server call is setup the same as the other data calls on the app too.

I should say, the whole reason I am filtering the results this way, is so I don't have to filter them via the app/backend. It seems a shame to have to put extra steps in the flow, when I should otherwise be able to pull exactly the information I need via the API call?

Perhaps there is something obvious I'm not seeing, or maybe there is a very strange bug that just doesn't allow this to work, but even PostMan displays the same feedback (All the data filters by GroupID as I want), so I'm quite dumbfounded... hopefully I'm not just dumb..

Any help is greatly appreciated!

Warm regards,

Josh


2026-01-03 13-44-38
Erwin van Rijsewijk
Champion
Solution

Hi Josh, I have found this post that looks similar to your problem. Maybe it helps:

https://www.outsystems.com/forums/discussion/66639/rest-api-parameters/

UserImage.jpg
Joshua McQuillan

Hi @Erwin  van Rijsewijk @Andrea Lembo, Erwin your link was the key to solving this.

I had a feeling there was going to be some issues with the names of my columns in SharePoint and how that would interact with my data in OutSystems.

I hadn't considered passing in the filter query as an entire variable and that solved my issue, after a little bit of testing for half an hour.

Firstly, the above link helped me get rid of the 400 status, and pretty damn quickly too, so I knew I was heading in the right direction, but then there was no data to display, despite passing the correct Id to SharePoint. My next challenge.

I think what it came down to was my specific call at this point. A few more tweaks and I had it sussed. It was essentially looking for a specific Id but because of special characters when they where passed directly from the API call, although it stopped providing a 400 status which is great, it created a new issue whereby the space in the encoded API call meant I was getting "..eq%2019"... 19 being my Group Id, and %20 being the space character, I'm sure this tricked the call into looking for a group with Id 2019.. which doesn't exist, so although the call wasn't getting an error 400, it wasn't quite there. After I found this though it wasn't long before I had my solution!

It's all working great right now and makes the call exactly as intended - so thank you for putting me on the right path Erwin :) very much appreciated!    

2022-04-19 13-20-22
Andrea Lembo

Hi,

Can you share the body response of the http request with the 400 status?


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