Consume REST API which request body has an Identifier

Hello all,

I exposed an API which gets an UserID  as an input. When I consume this API from a third party application(which does not know the entity identifier data type), I pass the identifier as either text/log int, which leads to the below error

"UserIdentifier compatible data type is required for UserID"

If I change the data type of the input parameter of the exposed API, I cannot use it to fetch the data from the aggregate. Can someone help me how to convert the data type from text/LongInt to UserId?

P.S: TexttoIdentifier() does not help


Solution

Hi @Madhavan Selvaraj,

Your Exposed API Parameter can be kept as LongInteger, Once the API reaches OS logic on the request you can convert the LongInteger received from the parameter to Identifier by LongIntegertoIdentifier() Function. And assign to your Local variable with User Identifier data type. Use this local variable for aggregate filtration.

Note: If your Expose API Input paramater is going to be Text, then Use LongIntegertoIdentifier(TexttoLongInteger()).

Please find the attached Oml for reference.

Regards,
Saravanan Santhanam.

OSPractice.oml

It worked perfect. Thank you :)

Hello Madhavan Selvaraj,

don't know the exact used case, but while consuming  you can add onafterresponse (from API pass userid as long integer) and in the on after response drag usertable with filter userid= API.userid and get the particular id


may be this will helps you

Thanks and Regards,

Akshay Deshpande


Thank you for your reply. But the application that consumes the exposed api is not an outsystem application

Solution

Hi @Madhavan Selvaraj,

Your Exposed API Parameter can be kept as LongInteger, Once the API reaches OS logic on the request you can convert the LongInteger received from the parameter to Identifier by LongIntegertoIdentifier() Function. And assign to your Local variable with User Identifier data type. Use this local variable for aggregate filtration.

Note: If your Expose API Input paramater is going to be Text, then Use LongIntegertoIdentifier(TexttoLongInteger()).

Please find the attached Oml for reference.

Regards,
Saravanan Santhanam.

OSPractice.oml

It worked perfect. Thank you :)

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