Error doing a POST request Omnis 8.1.3
Hi Alex,
Thanks for the quick response. I’ve added quotes to the MerchangeOrderNo en removed the square brackets and the combination of both made it work.
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@optimizegroup.be <mailto:an.bayens@optmizegroup.be>
www.justsoftware.be <www.justsoftware.be/> | www.optimizegroup.be <www.optimizegroup.be/>
<www.justsoftware.be/>
<www.justsoftware.be/> <www.justsoftware.be/nieuws/531-kmo-portefeuille> <www.facebook.com/optimizegroupBE> <www.linkedin.com/company/optimize-group> <www.linkedin.com/company/optimize-group>
> Op 10 jan. 2018, om 21:27 heeft Alex Clay <aclay@mac.com> het volgende geschreven:
>
> 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@justsoftware.be <mailto:an.bayens@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.rnTo 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
>> ]
>> }
>> }
>>
>> 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@optimizegroup.be <mailto:an.bayens@optimizegroup.be> <mailto:an.bayens@optmizegroup.be <mailto:an.bayens@optmizegroup.be>>
>> www.justsoftware.be <www.justsoftware.be/> <www.justsoftware.be/ <www.justsoftware.be/>> | www.optimizegroup.be <www.optimizegroup.be/> <www.optimizegroup.be/ <www.optimizegroup.be/>>
>
> _____________________________________________________________
> Manage your list subscriptions at lists.omnis-dev.com <lists.omnis-dev.com/>
_____________________________________________________________
Manage your list subscriptions at lists.omnis-dev.com