Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

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
0 REPLIES 0
Labels