POST request results in 400 error

2
I'm trying to use the Rest Services module to back up chat logs from our site to our Helpscout mailbox. For reference, the documentation for creating a conversation in helpscout is here: http://developer.helpscout.net/help-desk-api/conversations/create/ This is the domain model I have for a conversation: This is my startup microflow: This is the POST request microflow the CreateMicroflowService activity refers to. The input parameter for the POST activity is the Conversation entity: The POST request microflow is called on by another microflow which creates the conversation. The serializetoJson and message box activities are there so I can see what JSON is being generated for the POST request. According to that, the JSON code is correct and meets the requirements. However, when I try to send the POST request, I get a 400 error saying the value of the createdBy field is null. I can't figure out what would cause the createdBy fields to be null despite being populated when I look at the JSON in the message box. I'm testing this on my local instance and using postgres for the database. Please give me some ideas or suggestions on how to remedy this. Let me know if you need more details on something. EDIT: This is the JSON from the message box. I changed some of the values like emails and the mailbox ID: { "threads": [ { "body": "Hello", "createdBy": { "email": "andy@gmail.com", "type": "user" }, "createdAt": 1421955941700, "type": "chat" }, { "body": "How are you?", "createdBy": { "email": "andy@gmail.com", "type": "user" }, "createdAt": 1421955947317, "type": "chat" }, { "body": "Hi", "createdBy": { "email": "customer@gmail.com", "type": "customer" }, "createdAt": 1421955992153, "type": "chat" }, { "body": "I'm good.", "createdBy": { "email": "customer@gmail.com", "type": "customer" }, "createdAt": 1421955997047, "type": "chat" } ], "status": "active", "subject": "Chat Log", "customer": { "email": "andy@gmail.com", "type": "user" }, "type": "chat", "mailbox": {"id": 11111} } Here is the Error message and stack trace: An error has occurred while handling the request. [User 'adrewen' with session id 'a92731fc-d9a7-4efb-a7ad-da7cddb46e9f' and roles 'User, Administrator'] com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: restservices.consume.RestConsumeException: 400. Rest request failed: [HTTP Request: POST 'https://api.helpscout.net/v1/conversations.json' --> Response status: 400 Bad Request, ETag: null, body: '{"code":400,"error":"Input could not be validated","validationErrors":[{"property":"createdBy","value":null,"message":"The specified createdBy is not valid"}]}'] at HelpscoutAPI.ArchiveToHelpscout (JavaAction : 'post') at HelpscoutAPI.CreateChatLog (SubMicroflow : 'ArchiveToHelpscout') Advanced stacktrace: at com.mendix.modules.microflowengine.MicroflowUtil.processException(SourceFile:158) Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: restservices.consume.RestConsumeException: 400. Rest request failed: [HTTP Request: POST 'https://api.helpscout.net/v1/conversations.json' --> Response status: 400 Bad Request, ETag: null, body: '{"code":400,"error":"Input could not be validated","validationErrors":[{"property":"createdBy","value":null,"message":"The specified createdBy is not valid"}]}'] at com.mendix.core.component.InternalCore.execute(SourceFile:274) Caused by: com.mendix.core.CoreRuntimeException: restservices.consume.RestConsumeException: 400. Rest request failed: [HTTP Request: POST 'https://api.helpscout.net/v1/conversations.json' --> Response status: 400 Bad Request, ETag: null, body: '{"code":400,"error":"Input could not be validated","validationErrors":[{"property":"createdBy","value":null,"message":"The specified createdBy is not valid"}]}'] at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:210) Caused by: restservices.consume.RestConsumeException: 400. Rest request failed: [HTTP Request: POST 'https://api.helpscout.net/v1/conversations.json' --> Response status: 400 Bad Request, ETag: null, body: '{"code":400,"error":"Input could not be validated","validationErrors":[{"property":"createdBy","value":null,"message":"The specified createdBy is not valid"}]}'] at restservices.consume.RestConsumer.request(RestConsumer.java:484) at restservices.consume.RestConsumer.postObject(RestConsumer.java:642) at restservices.actions.post.executeAction(post.java:38) at restservices.actions.post.executeAction(post.java:20) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:199) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.hB.execute(SourceFile:42) at com.mendix.ik.a(SourceFile:47) at com.mendix.ij.a(SourceFile:193) at com.mendix.ij.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:199) at com.mendix.core.component.InternalCore.executeSync(SourceFile:235) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SourceFile:33) at com.mendix.ik.a(SourceFile:47) at com.mendix.ij.a(SourceFile:193) at com.mendix.ij.executeAction(SourceFile:148) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:53) at com.mendix.core.actionmanagement.CoreAction.doCall(SourceFile:291) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:276) at com.mendix.core.actionmanagement.ActionManager.executeSync(SourceFile:199) at com.mendix.core.component.InternalCore.execute(SourceFile:262) at com.mendix.iW.a(SourceFile:135) at com.mendix.pj$g.apply$mcV$sp(SourceFile:294) at com.mendix.pj$g.apply(SourceFile:285) at com.mendix.pj$g.apply(SourceFile:285) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(SourceFile:158) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(SourceFile:36) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(SourceFile:160) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(SourceFile:154) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(SourceFile:147) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
asked
0 answers