REST API learning path - Error while importing, key value for VehicleId should not be null.

1
An unexpected error occurred while handling REST request  -------- com.mendix.systemwideinterfaces.MendixRuntimeException: Error while importing, key value for 'VehicleId' should not be null.     at com.mendix.integration.importer.handlers.ObjectFinder.$anonfun$createArgs$1(ObjectFinder.scala:108)     at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)     at scala.collection.immutable.Map$Map1.foreach(Map.scala:128)     at scala.collection.TraversableLike.map(TraversableLike.scala:238)     at scala.collection.TraversableLike.map$(TraversableLike.scala:231)     at scala.collection.AbstractTraversable.map(Traversable.scala:108)     at com.mendix.integration.importer.handlers.ObjectFinder.createArgs(ObjectFinder.scala:100)     at com.mendix.integration.importer.handlers.ObjectFinder.findInDatabaseInternal(ObjectFinder.scala:65)     at com.mendix.integration.importer.handlers.ObjectFinder.findInDatabase(ObjectFinder.scala:55)     at com.mendix.integration.importer.handlers.ObjectFinder.$anonfun$find$1(ObjectFinder.scala:24)     at scala.Option.orElse(Option.scala:447)     at com.mendix.integration.importer.handlers.ObjectFinder.find(ObjectFinder.scala:24)     at com.mendix.integration.importer.handlers.ObjectMappingHandler.findObject(ObjectMappingHandler.scala:278)     at com.mendix.integration.importer.handlers.ObjectMappingHandler.getObjectViaDefaultAction(ObjectMappingHandler.scala:238)     at com.mendix.integration.importer.handlers.ObjectMappingHandler.getObjectImportInfo(ObjectMappingHandler.scala:107)     at com.mendix.integration.importer.handlers.ObjectMappingHandler.createObjectInfo(ObjectMappingHandler.scala:126)     at com.mendix.integration.importer.handlers.ObjectMappingHandler.$anonfun$endObjectElement$1(ObjectMappingHandler.scala:84)     at scala.Option.map(Option.scala:230)     at com.mendix.integration.importer.handlers.ObjectMappingHandler.endObjectElement(ObjectMappingHandler.scala:79)     at com.mendix.integration.importer.handlers.StreamingHandler.$anonfun$handleElement$1(StreamingHandler.scala:82)     at com.mendix.integration.importer.handlers.StreamingHandler.$anonfun$handleElement$1$adapted(StreamingHandler.scala:80)     at scala.Option.foreach(Option.scala:407)     at com.mendix.integration.importer.handlers.StreamingHandler.handleElement(StreamingHandler.scala:80)     at com.mendix.integration.importer.handlers.StreamingHandler.endObject(StreamingHandler.scala:70)     at com.mendix.integration.importer.json.JsonStreamingHandler.endElement(JsonStreamingHandler.scala:114)     at com.mendix.integration.importer.json.JsonStreamingHandler.parseObject(JsonStreamingHandler.scala:60)     at com.mendix.integration.importer.json.JsonStreamingHandler.parseFullArray(JsonStreamingHandler.scala:92)     at com.mendix.integration.importer.json.JsonStreamingHandler.parseArray(JsonStreamingHandler.scala:65)     at com.mendix.integration.importer.json.JsonStreamingHandler.$anonfun$parse$1(JsonStreamingHandler.scala:37)     at com.mendix.integration.util.AutoCloseableUtil$.using(AutoCloseableUtil.scala:10)     at com.mendix.integration.importer.json.JsonStreamingHandler.parse(JsonStreamingHandler.scala:30)     at com.mendix.integration.importer.json.JsonImporter.$anonfun$parseJson$3(JsonImporter.scala:50)     at scala.util.Try$.apply(Try.scala:213)     at com.mendix.integration.importer.json.JsonImporter.$anonfun$parseJson$2(JsonImporter.scala:50)     at com.mendix.integration.util.AutoCloseableUtil$.using(AutoCloseableUtil.scala:10)     at com.mendix.integration.importer.json.JsonImporter.$anonfun$parseJson$1(JsonImporter.scala:49)     at com.mendix.integration.util.AutoCloseableUtil$.using(AutoCloseableUtil.scala:10)     at com.mendix.integration.importer.json.JsonImporter.parseJson(JsonImporter.scala:48)     at com.mendix.integration.importer.json.JsonImporter.parse$1(JsonImporter.scala:37)     at com.mendix.integration.importer.json.JsonImporter.importStream(JsonImporter.scala:39)     at com.mendix.integration.internal.InternalIntegration.doImportStream(InternalIntegration.scala:98)     at com.mendix.integration.internal.InternalIntegration.doImportStream$(InternalIntegration.scala:86)     at com.mendix.integration.internal.InternalIntegrationImpl.doImportStream(InternalIntegrationImpl.scala:38)     at com.mendix.integration.service.rest.microflowarguments.ObjectOrListArgument.$anonfun$apply$2(ObjectOrListArgument.scala:56)     at scala.util.Success.flatMap(Try.scala:251)     at com.mendix.integration.service.rest.microflowarguments.ObjectOrListArgument.apply(ObjectOrListArgument.scala:42)     at com.mendix.integration.service.rest.microflowarguments.RestMicroflowArguments.bodyArgument(RestMicroflowArguments.scala:86)     at com.mendix.integration.service.rest.microflowarguments.RestMicroflowArguments.argument(RestMicroflowArguments.scala:68)     at com.mendix.integration.service.rest.microflowarguments.RestMicroflowArguments.$anonfun$apply$2(RestMicroflowArguments.scala:43)     at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)     at scala.collection.immutable.List.foreach(List.scala:392)     at scala.collection.TraversableLike.map(TraversableLike.scala:238)     at scala.collection.TraversableLike.map$(TraversableLike.scala:231)     at scala.collection.immutable.List.map(List.scala:298)     at com.mendix.integration.util.IteratorUtil$RichIterable$.toBreakoutMap$extension(IteratorUtil.scala:24)     at com.mendix.integration.service.rest.microflowarguments.RestMicroflowArguments.$anonfun$apply$1(RestMicroflowArguments.scala:42)     at scala.util.Try$.apply(Try.scala:213)     at com.mendix.integration.service.rest.microflowarguments.RestMicroflowArguments.apply(RestMicroflowArguments.scala:42)     at com.mendix.integration.service.rest.RestOperationProcessors.getMicroflowResult(RestOperationProcessors.scala:194)     at com.mendix.integration.service.rest.RestOperationProcessors.$anonfun$operationResponse$5(RestOperationProcessors.scala:127)     at com.mendix.basis.actionmanagement.IMonitoredAction$$anon$1.execute(IMonitoredAction.scala:47)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.basis.actionmanagement.IMonitoredAction.monitor(IMonitoredAction.scala:49)     at com.mendix.basis.actionmanagement.IMonitoredAction.monitor$(IMonitoredAction.scala:25)     at com.mendix.integration.service.ServiceMonitoredAction.monitor(ServiceMonitoredAction.scala:7)     at com.mendix.integration.service.rest.RestOperationProcessors.$anonfun$operationResponse$4(RestOperationProcessors.scala:125)     at com.mendix.integration.service.rest.RestOperationProcessors.withAuthenticationContext(RestOperationProcessors.scala:157)     at com.mendix.integration.service.rest.RestOperationProcessors.$anonfun$operationResponse$3(RestOperationProcessors.scala:120)     at com.mendix.integration.service.rest.RestOperationProcessors.operationResponse(RestOperationProcessors.scala:123)     at com.mendix.integration.service.rest.RestOperationProcessors.processOperations(RestOperationProcessors.scala:83)     at com.mendix.integration.service.rest.RestOperationProcessors.$anonfun$createProcessor$1(RestOperationProcessors.scala:62)     at com.mendix.integration.service.PathProcessors.$anonfun$process$3(PathProcessors.scala:32)     at scala.Option.fold(Option.scala:251)     at com.mendix.integration.service.PathProcessors.$anonfun$process$1(PathProcessors.scala:32)     at scala.collection.Iterator$$anon$11.nextCur(Iterator.scala:484)     at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:490)     at scala.collection.Iterator.isEmpty(Iterator.scala:385)     at scala.collection.Iterator.isEmpty$(Iterator.scala:385)     at scala.collection.AbstractIterator.isEmpty(Iterator.scala:1429)     at com.mendix.integration.util.IteratorUtil$RichIterator$.headOption$extension(IteratorUtil.scala:43)     at com.mendix.integration.util.IteratorUtil$RichIterable$.firstDefined$extension(IteratorUtil.scala:30)     at com.mendix.integration.service.PathProcessors.process(PathProcessors.scala:29)     at com.mendix.integration.service.PathProcessors.process$(PathProcessors.scala:28)     at com.mendix.integration.service.rest.RestOperationProcessors.process(RestOperationProcessors.scala:40)     at com.mendix.integration.requesthandlers.RestRequestHandler.$anonfun$processRequest$1(RestRequestHandler.scala:29)     at scala.collection.Iterator$$anon$11.nextCur(Iterator.scala:484)     at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:490)     at scala.collection.Iterator.isEmpty(Iterator.scala:385)     at scala.collection.Iterator.isEmpty$(Iterator.scala:385)     at scala.collection.AbstractIterator.isEmpty(Iterator.scala:1429)     at com.mendix.integration.util.IteratorUtil$RichIterator$.headOption$extension(IteratorUtil.scala:43)     at com.mendix.integration.util.IteratorUtil$RichIterable$.firstDefined$extension(IteratorUtil.scala:30)     at com.mendix.integration.requesthandlers.RestRequestHandler.processRequest(RestRequestHandler.scala:29)     at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:40)     at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:76)     at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:73)     at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)     at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.java:79)     at com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.java:988)     at com.mendix.m2ee.appcontainer.server.handler.RuntimeHandler.service(RuntimeHandler.java:42)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)     at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:755)     at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:547)     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)     at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1610)     at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)     at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1300)     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)     at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:485)     at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1580)     at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)     at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1215)     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)     at org.eclipse.jetty.server.Server.handle(Server.java:500)     at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)     at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)     at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)     at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)     at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)     at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)     at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)     at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)     at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)     at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)     at java.base/java.lang.Thread.run(Thread.java:834) I did all steps. Can't add new car with post method because of this error. Tried to put Integer instead of AutoNumber it didn't help much... It doesn't show this error message but what's even worse it doesn’t commit into database.
asked
2 answers
3

Hello Ivana and Albert,

I checked what was going wrong, and it is a bit sad, because after too much time I found out that the learning path page already contains the answer.

On the bottom of page https://academy.mendix.com/link/module/98/lecture/827/Add-a-POST-Method it says “Note: For version 8.6 and higher, the AutoNumber field Vehicle needs to be changed to Integer. We suggest to also change to "Create an object" to avoid getting a Null VehicleId error.”

This fixed the issue for me. Changing the VehicleId attribute to Integer and modifying the AddVehicles makes it possible to committing the Vehicle in the database (You add a ‘Create object’ action to your AddVehicles microflow where you copy all the values coming from input parameter Vehicle and you commit that object).  Before Mendix 8.6 this happened differently. You see that in the video after 1m 55s.

I will talk to my colleagues from the Mendix Academy, because I think this was unclear and should be improved.

Edit: I see the Academy now added a yellow border around the note. I hope that helps.

Regards,

Paul

answered
0

The message that you send with the test via the swagger documentation has the vehicleid set to an empty value. As this value is used to retrieve existing vehicles from the database the value can’t be empty (null).

In the video the vehicleid is set to zero and not null or empty. Changing this in the message should allow you to create the vehicle object via the POST action.

answered