cancel
Showing results for 
Search instead for 
Did you mean: 

Web API Services - Custom Code

JozefSovič
Level 2
Hello everyone

I have some small issues with API - Custom Code, I have no idea how to get it work correctly.

We just have in a company XXL APIs with tons of inputs and not all the inputs are mandatory and sometimes we don't have all values to fill-in in that particular time. Today I just added a 9th version of same API with a different JSON Body. So we just decided that we do not want to have hundred versions of the same API and we want to keep everything as simple as possible.

So I just want to create some really simple code that convert collection to JSON Template.
36665.jpg

The result of the function was tested without any issue when I changed the Action API - Body Content to Template and worked.

But What should I put it here to work ?
36666.png

Because this is throwing me a error 500.
Thank you for all the answers.

BR
2 REPLIES 2

PvD_SE
Level 12
Hi J,

While not being a programmer in the language used in the example: Wouldn't a TRY and CATCH combination provide you with more info on what goes wrong?

Happy coding!
---------------
Paul
Sweden
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

ewilson
Staff
Staff
@JozefSovič,

Any time you're creating custom code for the request there will be a default Out data item named Request_Content.​ You must set it with the final value that you expect to see in the body of your request. Here's an example:

36664.png
So, in your case you would end up with something like this:
Request_Content = ConvertToString(Data)​

Cheers,