Hello Infor Community,
I’m reaching out for assistance with a Python script I’m developing to fetch data from the Infor OS ION API. The script is intended to retrieve Quote and OrderLine records for the ZOELLERPUMP_TST tenant and save them into Delta tables in Microsoft Fabric. While the script successfully fetches Quote records, it fails to fetch OrderLine records, and I’m also encountering authentication issues that I’ve been unable to resolve. I’d appreciate any guidance or insights from the community to help me complete this script.
Background
- Objective: The script fetches Quote and OrderLine data from the Infor OS ION API and saves it into Delta tables (Quotes and OrderLines) in Microsoft Fabric for downstream analysis.
- Environment:
- Tenant: ZOELLERPUMP_TST
- API Base URL: https://cpqks.inforcloudsuite.com/RuntimeApi/EnterpriseQuoting/Entities
- Token Endpoint: https://mingle-sso.inforcloudsuite.com/ZOELLERPUMP_TST/as/token.oauth2
- Platform: Microsoft Fabric (using PySpark for data processing)
- Script Version: 20250321-10
- Authentication: Using OAuth2 with client_credentials grant type. I’ve been provided with a client_id and client_secret, which my manager confirms are correct.
The script successfully fetches Quote records, indicating that authentication and API access work for that entity. However, it fails to fetch OrderLine records, and I’m also encountering persistent authentication errors that prevent the script from running fully.
ssue 1: Authentication Failure with "Invalid ClientId" Error
Description: The script fails to authenticate with the Infor OS ION API, returning an Invalid ClientId error despite using credentials confirmed as correct by my manager.
Error Log (from script version 20250321-08):
textCollapseWrapCopy2025-03-21 18:39:44,211 - __main__ - ERROR - Failed to retrieve OAuth token from https://mingle-sso.inforcloudsuite.com/ZOELLERPUMP_TST/as/token.oauth2: 400 - {"error":"invalid_grant","error_trace_id":"Root=1-67ddb26f-770490ff6a21fa7d43a8dff3","error_description":"unauthorized_client: Invalid ClientId"}...2025-03-21 18:39:44,212 - __main__ - INFO - Attempting to retrieve token from: https://mingle-sso.inforcloudsuite.com/as/token.oauth22025-03-21 18:39:44,305 - __main__ - ERROR - Failed to retrieve OAuth token from https://mingle-sso.inforcloudsuite.com/as/token.oauth2: 400 - {"error":"invalid_grant","error_trace_id":"Root=1-67ddb270-68e873c266274ffb085792ee","error_description":"unauthorized_client: Invalid ClientId"}...2025-03-21 18:39:44,306 - __main__ - ERROR - Authentication test failed: All token URL attempts failed. Verify base_token_url, token_paths, client_id, and client_secret.
Details:
- The script uses the client_credentials grant type to request an OAuth2 token.
- Token endpoints tried:
- https://mingle-sso.inforcloudsuite.com/ZOELLERPUMP_TST/as/token.oauth2
- https://mingle-sso.inforcloudsuite.com/as/token.oauth2 (fallback without tenant)
- The script has been updated to try both passing credentials in the request body and using Basic Auth in the Authorization header, but the error persists.
- My manager confirms the client_id and client_secret are correct, so the issue might be with the token endpoint, tenant ID (ZOELLERPUMP_TST), or required scope.
Questions:
- Is https://mingle-sso.inforcloudsuite.com/ZOELLERPUMP_TST/as/token.oauth2 the correct token endpoint for the ZOELLERPUMP_TST tenant? If not, what should it be?
- Does the client_credentials grant type require a specific scope for this tenant? If so, what scope should I include in the token request?
- Could the Invalid ClientId error indicate a tenant mismatch or a configuration issue on the Infor side?
Issue 2: Script Fetches Quote Records but Not OrderLine Records
Description: Assuming authentication succeeds (as it does for Quote data), the script successfully fetches Quote records but fails to fetch OrderLine records. I suspect the OrderLine endpoint might be incorrect or requires different permissions.
Script Details:
- Base URL: https://cpqks.inforcloudsuite.com/RuntimeApi/EnterpriseQuoting/Entities
- Quote Endpoint: https://cpqks.inforcloudsuite.com/RuntimeApi/EnterpriseQuoting/Entities/Quote (working)
- OrderLine Endpoint: https://cpqks.inforcloudsuite.com/RuntimeApi/EnterpriseQuoting/Entities/OrderLine (not working)
- The script logs detailed responses for each API call, but I don’t have the latest logs for the OrderLine fetch since authentication is currently failing.
Potential Causes:
- The OrderLine endpoint might be incorrect. Possible alternatives could be /OrderLines (plural), /OrderItem, or a different path like /Orders/OrderLine.
- The client_id might lack permissions to access OrderLine data, even though it can access Quote data.
- There might be no OrderLine records available for the ZOELLERPUMP_TST tenant, though I’d expect an empty response ({"items": []}) rather than an error.
Questions:
- Is /OrderLine a valid endpoint under the Enterprise Quoting API suite? If not, what is the correct endpoint for fetching order line items?
- Does accessing OrderLine data require a specific scope or additional permissions compared to Quote data?
- How can I confirm the correct endpoint for OrderLine using the Infor OS Portal or API Gateway?
Issue 3: Schema Not Found Error in Microsoft Fabric
Description: Even when the script runs partially, it encounters a schema error when trying to verify the created tables in Microsoft Fabric.
Error Log (from script version 20250321-08):
textCollapseWrapCopy2025-03-21 18:39:48,542 - __main__ - ERROR - Failed to show tables: [SCHEMA_NOT_FOUND] The schema `My workspace.Test_Lakehouse_SB.9lsi0trfe9ln6s31c...` cannot be found. Verify the spelling and correctness of the schema and catalog.
Details:
- The script uses the schema 9lsi0trfe9ln6s31c..., which matches the output of SELECT current_database() in Microsoft Fabric.
- The error suggests Spark is interpreting the schema as My workspace.Test_Lakehouse_SB.9lsi0trfe9ln6s31c..., likely due to a catalog or namespace issue.
- I’ve updated the script to remove the default Test_Lakehouse_SB schema and confirm the lakehouse_schema value, but I haven’t been able to test this fix due to the authentication failure.
Questions:
- Is there a specific way to handle schema names in Microsoft Fabric when using PySpark with Infor data?
- Could this error be related to how the script constructs table names (e.g., `9lsi0trfe9ln6s31c...`.Quotes)?
Script Snippet
Here’s the relevant part of the script (version 20250321-10) that handles authentication and data fetching, for reference (see attached).
What I Need Help With
I’m looking for assistance with the following:
Authentication:
Confirm the correct OAuth2 token endpoint for the ZOELLERPUMP_TST tenant.
Identify any required scope or configuration to resolve the Invalid ClientId error.
OrderLine Endpoint:
Verify the correct endpoint for OrderLine data in the Enterprise Quoting API suite (or another suite if applicable).
Confirm if additional permissions are needed to access OrderLine data.
Schema Issue in Microsoft Fabric:
Guidance on handling schema names in Microsoft Fabric to avoid the SCHEMA_NOT_FOUND error.
Any insights, suggestions, or examples from your experience with the Infor OS ION API would be greatly appreciated. I can provide additional logs or script details if needed. Thank you in advance for your help!
Best regards,
Scott Badger
System Analyst/Power BI Developer