In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Python tool returning .yxdb error but my code isnt writing to a yxdb?

nickmartella
7 - Meteor

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
1 REPLY 1
marcoush
5 - Atom

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

Labels
Top Solution Authors