Solved

REST API Search SR not returning project_id

  • 1 November 2022
  • 5 replies
  • 128 views

Badge

Hello. I am trying to do a search of our service records using the REST API. I am able to successfully login and do a sr search. I retrieve all the records but I am missing a piece of data I would like to display to my users from this search. 

 

On our system I would like to retrieve this piece of information. 

 

 

If I do a request and pull this record individually, the data is in the key “project_id”. 

 

This is missing from a sr search. Is it possible to request this field in my query? Do I need to define a view or something like that? I tried adding parameter's to my request in the field parameter but that didn’t seem to help. Our default view does show this information.

 

Or do I need to write a loop from the first search to pull each sr and find that piece of data that was missing?

 

This is my search request to start with that seems to return everything I need but one field. 

 

Thank you. 

icon

Best answer by Erik Snider 9 November 2022, 10:29

View original

5 replies

Userlevel 5
Badge

Hi @BeckhoffGuy 

Good one!

I consulted with our experts and they suggested you create a dedicated view with a static filter that includes the criteria related to the project id you want, and then perform the query on this view and it will pull the data. 

here is an example:

Let us know how it goes!

 

Badge

Thank you for the quick response. So I tried your suggestion. I made a new view see below. That just is the fields I want to pull into a search. 

 

I then tried the same search but with that view. project_id doesn’t come up. I get the id, description and title. 

Any further suggestions would be greatly appreciated. If that field can’t be returned in a sr search, it looks like I will have to do a two step process. Do a search for all service records that contain what I am looking for , store all this sr id’s then in another loop that pulls all the data for each sr and get the project_id. If that is the case that is a little bit of a bummer. 

 

I also tried a query like you posted. It returns all the cases in the system and still doesn’t return the project_id. Same thing as above. just the id, description and title.

 

Badge

Any update on this request? I am assuming that field can’t be returned in a sr search. I wanted to ask before writing a bunch of code to retrieve the data I need. 

Badge

So I ended up just having to write another loop to take the returned sr ID#’s and then pull each case individually and then loop through that data and pull the project_id. Makes it take longer but it works. 

Userlevel 2

Hi @BeckhoffGuy,

I’ve consulted with our experts and we are not able to recommend a better workaround from what you’ve been able to do.

Best wishes,

Erik

Reply