Python tool returning .yxdb error but my code isnt writing to a yxdb?
Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
nickmartella
7 - Meteor
04-15-2024
06:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello, in my python tool I am doing an API POST call and I only want the returned data to go downstream in my workflow. However, my code is returning the following metadata error.
Here is my code:
import requests
import json
from ayx import Alteryx
import pandas as pd
df = Alteryx.read("#1")
Token = df["JSON_ValueString"].values[0]
url = "(placeholder url)"
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {Token}',
'Cookie': '(placeholder)'
}
responses = []
for part_number in df["SUPPLIER_PART_NUMBER"]:
payload = {
"transactionId": "1111",
"externalPartnerNumber": "",
"departmentNumber": "",
"locale": "en",
"sections": [],
"identifiers": {
"mmmStockNumber": part_number,
"upc": "",
"mmmCatalogNumber": part_number,
"customerPartNumber": part_number,
"requestedDeliveryQty":"1"
}
}
response = requests.request("POST", url, headers=headers, json=payload)
if response.status_code == 200:
response_data = response.json()
responses.append(response_data)
df_responses = pd.DataFrame(responses)
Alteryx.write(df_responses, 1)
error
SUCCESS: reading input data "#1"
[Datafile.writeData]: metadata arg is required for yxdb and expected to be dict like {'Field1': {'type': 'FixedDecimal', 'length': (8, 3), 'source': 'PythonTool:', 'description': 'my description'}, 'Field2': {...}}
Error: unable to write output (C:\Users\nmartella\AppData\Local\Temp\Engine_15176_59528846cac4401382bf420bd17f360d_\d827adaccb4f5027467ed3663ce95353\output_1.yxdb)
ERROR: writing outgoing connection data 1
Labels:
- Labels:
- Python
1 REPLY 1
marcoush
5 - Atom
04-07-2025
02:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I have the same issue. I try to convert my dataframes to yxdb output using the usual way (i even got a dictionary set up) but always get this error:
TypeError: [Datafile.writeData]: metadata arg is required for yxdb and expected to be dict like {'Field1': {'type': 'FixedDecimal', 'length': (8, 3), 'source': 'PythonTool:', 'description': 'my description'}, 'Field2': {...}}Any updates on the front?
Update from me: The error in my case derived from no elements in the dataframe. So yeah it was just " not the right " error message for me... maybe that helps sb.
Greetz, Marc
