It seems like you are trying to use draftOrderCreate and orderUpdate mutations in a GraphQL API to add localization extensions for Brazilian and Mexican tax credentials. Here’s a breakdown of your issue and suggestions on how to resolve it.
Problem Summary:- You are able to successfully set TAX_CREDENTIAL_BR (Brazil) during the orderUpdate mutation.
- However, when you attempt to set TAX_CREDENTIAL_MX (Mexico), you get an “invalid key” error.
- Both keys seem to be used in draftOrderCreate, but neither is set in the result.
Potential Causes and Solutions:1. Invalid Key for Mexico:
- The error message you received indicates that the key TAX_CREDENTIAL_MX is invalid. This suggests that either:
- TAX_CREDENTIAL_MX is not a valid key in your system, or
- The API doesn’t recognize TAX_CREDENTIAL_MX for the localizationExtensions field.
Solution:
- Check the API documentation to see if TAX_CREDENTIAL_MX is a supported key. It’s possible that the correct key for Mexico might be something else, like RFC_MX (for Registro Federal de Contribuyentes) or another valid identifier.
-
Schema Mismatch:
- The system might not have been configured to handle TAX_CREDENTIAL_MX in certain mutations (such as orderUpdate). Some systems might have specific validation for the available keys.
Solution:
- To troubleshoot, try a different key for Mexico. You might need to use an alternate key for tax credentials like RFC_MX or another supported key.
-
Localization Extensions in draftOrderCreate:
- You mentioned that localizationExtensions were not set in the result of draftOrderCreate, which indicates the API did not accept or save the localization data properly during the creation of the draft order.
Solution:
- Ensure the correct format and API behavior for draftOrderCreate. It’s possible that draftOrderCreate might require additional setup or validation to allow localization extensions to be added.
- Test by adding localization extensions in a different format, or try using only one key (e.g., TAX_CREDENTIAL_BR) and see if the issue persists for draftOrderCreate.
-
API Configuration and Permissions:
- There could be an issue with how your API is configured to handle localization extensions for Mexico. Ensure that the API you’re working with has the proper configuration to handle both BR and MX tax credentials, and that the system supports them.
Suggested Actions:1. Test with different localization keys: Try replacing TAX_CREDENTIAL_MX with a known valid key like RFC_MX (for Mexico), as it might be the correct key for tax credentials in Mexico.
-
Check API documentation for localization keys to confirm if TAX_CREDENTIAL_MX is a valid key for localization extensions or if there is an alternate key like RFC_MX.
-
Check for API updates or restrictions: Some APIs have limitations or updates that might restrict or validate specific keys. Ensure the system supports both BR and MX credentials properly.
-
Validate during Draft Order Creation: If draftOrderCreate is not setting the localization extensions, check the API’s handling of localization data at that stage. If needed, refer to the API’s official documentation for creating draft orders with custom localization extensions.
-
Test with simple data: Test the system by setting only one localization key (e.g., TAX_CREDENTIAL_BR for Brazil) in both draftOrderCreate and orderUpdate to check if the issue is specific to the combination of keys.
Example GraphQL Request for Testing:
You can modify your request like this to test the new key:
{
"input": {
"localizationExtensions": [{
"key": "RFC_MX",
"value": "HEGA820506M10"
}]
}
}
Conclusion:
The core issue seems to be related to invalid key for Mexico (TAX_CREDENTIAL_MX). Double-check the API documentation to confirm the correct key, and consider using alternatives like RFC_MX for Mexico.