3

When I am trying to run Data hub flow from REST API using the POST method, I am getting bad request error. I am using postman to run the below flow. I have followed the documentation https://docs.marklogic.com/datahub/flows/run-flow-using-rest-client-api.html

But I am able to run the flow using gradle tasks. Can any one help me?

http://localhost:8230/v1/resources/ml:runFlow?rs:flow-name=flow_name&rs:step=1

I am getting following error

{ "errorResponse": { "statusCode": 400, "status": "Bad Request", "messageCode": "XDMP-ARGTYPE", "message": "XDMP-ARGTYPE: cts.query(\"cts.andQuery([cts.collectionQuery(\\"test_coll"\\"), ...\") -- arg1 is not of type Node" }

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
  • Where is the cts.andQuery part coming from? cts.query does not accept quoted queries.. – grtjn Mar 02 '20 at 08:50
  • Its part of the flow. Have created flow using quick start. Please note this flow is executing fine using gradle hubRunFlow. I am facing the issue only when I try to run the flow from REST API end point. – Niranjan Raja Mar 02 '20 at 10:14
  • 1
    I believe you are hitting this error due to not providing the URIs of the documents to you wish to run the flow against in the options object. Can you verify you're not passing in something like `&rs:options={ "uris" : [ "comma-separated","uris","of","records","to","process" ] }`? If that is the case, I'll provide a more detailed answer as to why those URIs in the options are needed and suggest that a GitHub issue be filed to throw a better error in this situation. – justdewit Mar 02 '20 at 23:37
  • Thank you 'justdewit'. I have just figured that I am not passing URI and its required. I thought URI is an optional parameter. Yes, It would be great if we get a better error and also documentation could be updated with some exmaple's or clarity on the required parameters. Thank you again :) – Niranjan Raja Mar 03 '20 at 07:45

1 Answers1

2

In order to use the mlRunFlow REST extension, URIs of the documents must be passed into the endpoint. The endpoint must be driven by en external orchestration tool to manage batching/threads and work distribution. You can read more about batching/threads performance considerations here.

You're encountering that error message due to an attempt to a portion of the code attempting to run against an entire set of documents matching a source query when the URIs aren't present. That isn't supported and the endpoint should be throwing an explicit error about the missing URIs. I've filed a GitHub issue here.

justdewit
  • 231
  • 2
  • 6