Error doing a POST request Omnis 8.1.3

An an.bayens at justsoftware.be
Wed Jan 10 15:17:08 EST 2018


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/>
 

> Op 10 jan. 2018, om 16:48 heeft An <an.bayens at justsoftware.be> het volgende geschreven:
> 
> Hi Bruno,
> 
> Thanks for the answer, that was indeed the solution.
> 
> 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 optimizegroup.be> <mailto:an.bayens at optmizegroup.be <mailto:an.bayens at optmizegroup.be>>
> www.justsoftware.be <http://www.justsoftware.be/> <http://www.justsoftware.be/ <http://www.justsoftware.be/>> | www.optimizegroup.be <http://www.optimizegroup.be/> <http://www.optimizegroup.be/ <http://www.optimizegroup.be/>>
> 
>> Op 10 jan. 2018, om 11:49 heeft Bruno Del Sol <bruno.delsol at bydesign.fr <mailto:bruno.delsol at bydesign.fr>> het volgende geschreven:
>> 
>> Hi An,
>> 
>> You are using the "old" http client which has a dependency with Java.
>> 
>> With 8.1.3, you should rather user the new OW3 worker object, which doesn't have this flaw.
>> 
>> Have a look at the library at Hub / Samples / HTTP OW3 worker object for a working example of POST request
>> 
>> Regards
>> Bruno
>> 
>> 
>> By Design
>> http://www.bydesign.fr <http://www.bydesign.fr/> <http://www.bydesign.fr/ <http://www.bydesign.fr/>>
>> Bruno Del Sol
>> bruno.delsol at bydesign.fr <mailto:bruno.delsol at bydesign.fr> <mailto:bruno.delsol at bydesign.fr <mailto:bruno.delsol at bydesign.fr>>
>> tel (33) 01 48 78 47 37
>> 46, rue de La Tour d'Auvergne
>> 75009 Paris (France)
>> 
>> Le 10/01/2018 à 11:21, An a écrit :
>>> Hi all,
>>> 
>>> I’m having a problem with Omnis 8.1.3 with doing a POST request in JSON. I get the error that the Java Native Interface couldn’t be initilalized.
>>> 
>>> This is what I do in my code:
>>> 
>>> Do method $BuildListHeader ('POST')
>>> 
>>> Calculate iURL as 'xando.channelengine.net <http://xando.channelengine.net/> <http://xando.channelengine.net/ <http://xando.channelengine.net/>> <http://xando.channelengine.net/ <http://xando.channelengine.net/> <http://xando.channelengine.net/ <http://xando.channelengine.net/>>>'
>>> 
>>> Calculate iURI as con(iURL,'/',iAPIname,'?apikey=',ivChannelEngineApiKey)
>>> 
>>> Do iRestfulObj.$init(iURI,kOWEBhttpMethodPost,iListHeaders,iContentBinary)
>>> Do iRestfulObj.$run() Returns lStatus
>>> If lStatus
>>> 	Do iRestfulObj.$returnJSON(iResponseHeaders,iRowResponse,iRowJSON) Returns iJSONString
>>> 	Calculate msg as con(iAPIname,' ',iRowJSON.code,' ',iRowJSON.object.$colcount)
>>> Else
>>> 	Calculate msg as iRestfulObj.$errortext
>>> End If
>>> If iRowResponse.httpStatusCode>=200&iRowResponse.httpStatusCode<=209
>>> 	Calculate ok as kTrue
>>> Else
>>> 	Calculate msg as con(iAPIname,' ',iRowResponse.errorCode,' ',iRowResponse.errorInfo,' ',iRowResponse.httpStatusCode,' ',iRowResponse.httpStatusText)
>>> 	Calculate ok as kFalse
>>> End If
>>> If iRowJSON.code<>'200'
>>> 	Do iListResponseCodes.$search($ref.C1=iRowJSON.code,kTrue,kFalse,kFalse,kFalse)
>>> 	Calculate msg as con(iAPIname,' ',iRowJSON.code,' ',iListResponseCodes.description)
>>> 	Calculate ok as kFalse
>>> End If
>>> Quit method ok
>>> 
>>> The result of the iRestfulObj.$run is an error which is  Java Native Interface couldn’t be initilalized.
>>> 
>>> Thanks in advance.
>>> 
>>> Met vriendelijke groeten,
>>> An Bayens
>>> Product Manager
>>> 
>>> _____________________________________________________________
>>> Manage your list subscriptions at http://lists.omnis-dev.com <http://lists.omnis-dev.com/> <http://lists.omnis-dev.com/ <http://lists.omnis-dev.com/>>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com <http://lists.omnis-dev.com/>



More information about the omnisdev-en mailing list