Free Trial

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Alteryx Server API Queries - Difficulty Getting Body to Pass Properly

Brando
8 - Asteroid

Hey Alteryx Community,

 

I'm developing a pipeline for some data that requires the use of the Alteryx Server / Gallery API using python. I've successfully gathered the authorization token from the API and can ping workflows sitting on my company's gallery; however, I'm struggling to pass a body through the questions in the analytic app interface.

 

I'm thinking I need to pass a more detailed JSON, but am unsure how to structure it. The workflow has a JSON parse tool and is designed to take the body from the interface. However; it fails to pass when I ping the API. Any ideas on troubleshooting?

 

My body looks like this: 

 

'{"test": "testTwo"}'

 

Below is an image of what the interface looks like.

 

3 REPLIES 3
fmvizcaino
17 - Castor
17 - Castor

Hi @Brando ,

 

Firstly, I would recommend accessing Swagger; you can test and see the JSON structure to be sent.

Screenshot 2024-05-21 132823.png

Access the API V1 on the drop-down at the top and clicking on Explore

There you will have access to this endpoint here and on the right side you will see the Json structure to be followed.

Screenshot 2024-05-21 133111.png

 

{
"questions": [
{
"name": "string",
"value": "string"
}
],
"priority": "string"
}

 

You don`t need to include the priority. The name will be the tool name and the value is what is inside your Json Input box, as follows.

{
"questions": [
{
"name": "Text Box (2)",
"value": "testTwo"
}
]
}

 

Text Box (2) is coming from the tool`s annotation page.

Screenshot 2024-05-21 133635.png

 

If you are not entirely sure where to get the tool name, you also have this endpoint here that will return all the interface tools and their names from a Gallery workflow.

/v1/workflows/{appId}/questions

 

Best,

Fernando Vizcaino

 

Brando
8 - Asteroid

@fmvizcaino Thanks for the detail, so I operated the questions endpoint and received the following:

[{'name': 'Text Box (5)', 'questionType': 'QuestionTextBox', 'description': 'JSON_Input', 'value': '', 'multiple': False, 'items': []}]

 

However, when I pass the following back into the body:

body = '''[{'name': 'Text Box (5)',
  'questionType': 'QuestionTextBox',
  'description': 'JSON_Input',
  'value': '',
  'multiple': False,
  'items': []}]'''

I get the following response from the API:

{'id': '664ce952d53b0000dc003637', 'appId': None, 'createDate': '2024-05-21T18:34:58.7250168Z', 'status': 'Queued', 'disposition': 'None', 'outputs': [], 'messages': [], 'priority': 'Low', 'workerTag': '', 'runWithE2': True}

I'm guessing there should be something in the messages? What are your thoughts?



fmvizcaino
17 - Castor
17 - Castor

Hey @Brando ,

 

You only need to include the name and value as follows:

{
"questions": [
{
"name": "Text Box (5)",
"value": ""
}
]
}

 

But from the response, it looks like the workflow is on the Queue and will run.

 

Next, you can use the /v1/jobs/{id} to check the workflow status (running or completed). The jobID is the one you got in the response (664ce952d53b0000dc003637)

 

After completion, if you have outputs you want to download, you can use this endpoint here. /v1/jobs/{id}/output/{outputId}.

JobID: 664ce952d53b0000dc003637

OutputID: If any, you will get the ID from this  /v1/jobs/{id}

 

Best,

Fernando Vizcaino