It’s been a long day so apologies if this is a really dumb question.
I have a function that has a string parameter intended to consume information related to what will be line level details in a quote or sales order.
The parameters for the function look like this:
the “productList” is filled out by a nested array like so:
Is this invalid JSON or something? I think it looks fine but more eyes are helpful.
next, when I consume this parameter, I was having trouble iterating over it as it keeps throwing back the “Sorry! Something went wrong” message to my app.
I am trying to debug this bug it’s not even allowing to read the incoming productList parameter into the output parameter “msg”
Was this working before or is it shown like this in the documentation or examples?
I have no idea how the productList property is parsed into the function or if it is even supported like this.
Another way would be to simply format the productList as a list of separated values in a single string.
In this case I’m just trying to pass the raw values from the parameters into my function and then process fr there. It works great with single string values but I’m having trouble with sending it more complex json like this example. I didn’t read any documentation regarding this so apologies if that’s a known barrier or if I’m just doing it wrong
You know what would be cool is a dynamic object type in addition to the existing data types that are allowable for the parameters
Hi Aaron,
That’s the reason, the product list is a built-in ref type “System.String” and not an array or collection, so, unless Epicor adds additional types for request/response parameters, you will need to send a list as a string, for example:
“productList”: “32247001,45647010,…”
or
“productList”: “PartNum-32247001,PartNum-45647010,…”
then in your C# code you split to an array and do your iteration.
I think I had to jsonify the inner objects into a string first and then jsonify the whole string object…and then do the reverse in the Function. It might be worth reporting to Epicor.
What I didn’t try was seeing if URL encoding would have helped.
Where are you processing the array of property productList in your function. That is likely where it is breaking. You have to make sure you are handling that deserialized object correctly. If you are passing the whole Json String is into your function it’s just a string. Show the code that deserializes and process the productList.
It’s POST data, URL encoding shouldn’t enter into it in this case. He was showing passing the data to the function directly from postman where it will not work either so it’s for sure on the Epicor processing side the issue lies, not with how he’s sending it.
Right. I was just wondering if Epicor is getting tripped up by the braces or brackets and encoding might prevent that issue during the Epicor parameter processing. Just throwing out ideas.
I get that. I’m suggesting that Epicor might be handling this free-for-all poorly and looking to see how changing the payload (like Aaron did by making it a string) might change the post-POST processing.
In this example I’m not even processing it yet. I’m just trying to figure out if it is being consumed at all into the function.
I also tried deserializing it and then displaying it in the msg output variable, but no dice.
So I tried then to not deserialize it in hopes that jt was being fed a raw json string and that fails too.
It looks like like it might be trying to parse it to a .net type without me knowing and perhaps that’s why it is not allowing it to be consumed if it’s anything other than a string or an int
I’m worried you’re right, but if this is the case it’s a pretty cruddy design if we can’t use actual json objects to pass into functions. I’ll give that a shot too