Forum Discussion
Does using the error handling (Discard/Route to Error View) not resolve this?
jfpelletier - Welcome to the Community. To fix your JSON Generator, I believe you simply need to change how you're referencing the value. Try this:
{ "name" : $splitValue, "customerId" : 771373363, "templateId" : 8672995468 }
Or you could try using the Mapper snap, which simplifies the construct of these JSON objects since it directly maps the JSON paths in source to target expressions. The same construct as above is done in a Mapper as follows:
I hope this helps!
- jfpelletier2 years agoContributor
Hello koryknick,
Thanks a lot for your reply, both options work to give me the correct JSON that I need. 🙂
I prefer the one with the mapper, it seems simpler to me.
The results in the following snap are not good however, I'm getting a 415 error message from the server to which I'm sending this payload.
If I manually enter value for the payload, it works well, the other system returns a 202 (success).
However, if I use the results from the previous snap (the JSON structure that I just generated) as multi-part, I'm getting the 415 error message:
The small characters: Failure: class java.util.LinkedHashMap cannot be cast to class java.lang.String (java.util.LinkedHashMap and java.lang.String are in module java.base of loader 'bootstrap'), Reason: Snap failed unexpectedly and did not provide any reason.
I must be doing something very wrong... Can you see why it's not working?
Thanks!
JF
jfpelletier - it looks like you need to change your Multipart Form "Key" names into static strings by disabling the expression button and removing the $. So it would look like this:
Hope this helps!
- jfpelletier2 years agoContributor
Hello koryknick,
Thanks for your reply!
I'm unfortunately getting the same error, please see screenshot below. I'm also wondering how I can dynamically get the project name if I remove the expression button, isn't it how I can get the field values?
Thanks,
JF
Actually, the Content-Type should probably be "text/plain" since the values you are sending are just a string or numeric - it's not really JSON. I believe that is what is complaining about at this point.
Let me know if that still doesn't work.
- jfpelletier2 years agoContributor
Hello again koryknick,
Thanks for your quick input!
I'm unfortunately having the same error when I change the Content-Type:
Kind regards,
JF
I didn't notice before, but you don't want to have anything in the Multipart sub-type property. Clear that $ from the expression and uncheck the expression enabler.
- jfpelletier2 years agoContributor
Hello again koryknick,
Thanks again, it worked this time! 🙂
The only change I made to your reply was to enabling the expression button for the "name" field and get the value from the passed list otherwise all my projects were labelled "name":
It's all good now, thanks a lot again for your help!
Kind regards,
JF
Related Content
- 2 years ago
- 11 months ago
- 5 years ago
- 11 months ago