# Matching Option set Type with an API response

**URL:** <https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700>\
**Category:** APIs\
**Created:** [April 28, 2020, 9:10am UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700 "2020-04-28T09:10:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthur.kieffer](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/arthur.kieffer/32/111269_2.png) [@arthur.kieffer](https://forum.bubble.io/u/arthur.kieffer)\
**Post date:** [April 28, 2020, 9:10am UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700/1 "2020-04-28T09:10:00Z")

</div>

Hello guys, have anyone of you already tried to match a response API object to an Option Set Type and succeeded ?

I want to match categories of items to my list of categories (as option set).

Example : API response " category : ‘CAT1’ " initialized as type Category (option set type).  
My option set Category has 5 entries from CAT1 to CAT5 (named in their “display” attribute). Unfortunately , when calling the request I always get an empty value on this object, so I assume Bubble doesn’t manage to match the response to an entry in my option set.

So, is it even possible to do so , and if it is, what am I doing wrong ?

---

<div class="post-metadata">

**Author:** ![ambassa.steve](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ambassa.steve](https://forum.bubble.io/u/ambassa.steve)\
**Post date:** [July 16, 2020, 7:47pm UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700/2 "2020-07-16T19:47:39Z")

</div>

Hi Arthur,  
Did you find a solution to your problem?

---

<div class="post-metadata">

**Author:** ![arthur.kieffer](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/arthur.kieffer/32/111269_2.png) [@arthur.kieffer](https://forum.bubble.io/u/arthur.kieffer)\
**Post date:** [July 17, 2020, 7:34am UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700/3 "2020-07-17T07:34:35Z")

</div>

Hi Steve,  
Unfortunately I didn’t … I guess the only solution at the moment is by using the database for that kind of data.

---

<div class="post-metadata">

**Author:** ![ambassa.steve](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ambassa.steve](https://forum.bubble.io/u/ambassa.steve)\
**Post date:** [July 22, 2020, 2:13pm UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700/4 "2020-07-22T14:13:32Z")

</div>

Hi Arthur,

Got it thank you for your answer.

---

<div class="post-metadata">

**Author:** ![noyourbroker](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@noyourbroker](https://forum.bubble.io/u/noyourbroker)\
**Post date:** [August 11, 2021, 8:28pm UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700/5 "2021-08-11T20:28:04Z")

</div>

Hey @arthur.kieffer , I’m not sure if this is what you need but I stumbled upon this thread and thought I’d try to help.

Is it possible to have your options exist in the DB and as an option set? That way your API call can match the DB but you can filter by options in the UI? I read/watched [this thread](http://forum.bubble.io/t/getting-creative-with-rgs-option-sets/83224) last night and it details how to do that.

Let me know if that’s helpful or if I’ve misunderstood your question.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![anon91331491](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@anon91331491](https://forum.bubble.io/u/anon91331491)\
**Post date:** [October 11, 2021, 9:38am UTC](https://forum.bubble.io/t/matching-option-set-type-with-an-api-response/88700/6 "2021-10-11T09:38:36Z")

</div>

I had an API that returns a numeric value for ‘Role Number’, with say 13 = Manager, 22 = Clerk etc. I defined these as an Option Set type OSRole with Display attribute Manager, Clerk etc. and an additional attribute Role Number defined so that I have

OSRole - Type:  
Display: text  
Role Number: number

OSRole - Data  
Display: Manager, Role Number: 13  
Display: Clerk, Role Number: 22  
etc.

My API response includes the Role Number, and I want to convert that in a Workflow into an element within the OSRole type.

To do this I used:

(assuming API response is in a state ‘API Response’)

Set State:  
Element: whatever  
Custom State: API Role (with type OSRole)  
Value: **All OSRole:filtered:first item**

The List Filter has a single constraint,  
**This OSRole’s Role Number is API Response’s Role Number**

If the API Response’s Role Number doesn’t match an element within the OSRole option set, the result will be empty.

To get ‘All OSRole’, in the Value field select ‘Get an option’, select your Option Set and choose All options. This returns a list of all elements in the Option Set. You then filter that list with a constraint that matches only on the Role Number attribute, ideally that should return a list with a single element, and you convert that into an OS element by picking the first element in that list.

Hope this helps.  
Tim.
