Error doing a POST request Omnis 8.1.3

Alex Clay aclay at mac.com
Wed Jan 10 15:27:38 EST 2018


Hi An,

> [     {         "MerchantOrderNo": 1001598,         "OrderId": 1     } ] 

is different from:

> {
>  "MerchantOrderNo": "string",
>  "OrderId": 0
> }

in two regards. First, you might need to force the value for MerchantOrderNo to be a string so it's quoted:

> [     {         "MerchantOrderNo": "1001598',         "OrderId": 1     } ] 


Second, the square brackets denote an array. The error message you shared suggests the API will be ok with an array, but if changing the string type doesn't help try stripping off the square brackets:

>  {         "MerchantOrderNo": "1001598',         "OrderId": 1     } 


Alex


> On Jan 10, 2018, at 15:17, An <an.bayens at justsoftware.be> wrote:
> 
> Hi All,
> 
> After making a huge step thanks to Bruno I've now ran in to a new error.
> 
> As content for my post I send this in JSON format. 
> 
> [     {         "MerchantOrderNo": 1001598,         "OrderId": 1     } ] 
> 
> This is created using following code:
> Do OJSON.$listorrowtojson(iList,,errorText) Returns iContentBinary
> Do OJSON.$formatjson(iContentBinary) Returns iContentChar
> Calculate iContentChar as replaceall(iContentChar,kCr,' ')
> 
> 
> This matches with the API reference which say's it should be this
> {
>  "MerchantOrderNo": "string",
>  "OrderId": 0
> }
> 
> But I get following error message. Can it be that this is also something that changed using the new OW3 Worker Object?
> {
>    "StatusCode": 400,
>    "Success": false,
>    "Message": "Some fields did not pass validation, see ValidationErrors for details.",
>    "ValidationErrors": {
>        "model": [
>            "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'MM.WebApi.App.ViewModels.OrderAcknowledgementViewModel' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath '', line 1, position 1."
>        ]
>    }
> }
> 
> Thanks very much for helping a Omnis newbie :)
> 
> 
> Met vriendelijke groeten,
> An Bayens
> Product Manager
> 
> Stationsstraat 266, B-1700 Dilbeek
> T. +32 2 567 21 71
> Helpdesk: +32 2 568 14 54
> 
> an.bayens at optimizegroup.be <mailto:an.bayens at optmizegroup.be>
> www.justsoftware.be <http://www.justsoftware.be/> | www.optimizegroup.be <http://www.optimizegroup.be/>




More information about the omnisdev-en mailing list