Error Creating Invoice in Xero from Pipedrive via Pipedream Using Organization ID?

This topic was automatically generated from Slack. You can find the original thread here.

Hi there, when I am using organization ID to create an invoice in Xero from pipedrive via pipedream I am getting this error. Please help me in this one
Screenshot by Lightshot, Screenshot by Lightshot

could you copy and paste that error here?

Error - Request failed with status code 400
{“ErrorNumber”:14,“Type”:“PostDataInvalidException”,“Message”:“JSON for post data was invalid,Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type ‘System.Guid’ because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath ‘Contact.ContactID.active_flag’, line 1, position 55.”}
DETAILS

steps.xero_accounting_api_xero_create_sales_invoice{1}
debug{5}

can you help debug the error above? This is using the Xero Create Sales Invoice action

It looks like you’re encountering a JSON deserialization error when creating a sales invoice in Xero. The error message points to an issue with the Contact.ContactID.active_flag field in the JSON object. To help you further, I’ll need more information about the data you’re sending to the Xero Create Sales Invoice action. Can you please provide the JSON object you’re using in the action, or share the relevant part of your Pipedream workflow? This will help me identify the issue and suggest a solution.

Thanks . Can you tell me more about HTTP 400 errors in general?

HTTP 400 errors, also known as “Bad Request” errors, occur when a client sends a request to a server that is malformed or invalid. This can happen for various reasons, such as incorrect syntax, invalid data, or missing required fields in the request. The server is unable to process the request and returns a 400 error to inform the client that there’s an issue with the request they sent. To resolve a 400 error, you’ll need to review the request and correct any issues before resending it.

when I am using contact ID as a number value like this - Screenshot by Lightshot, it gives me an error like this - Screenshot by Lightshot so what is the solution here? @UMT4G7E5P

It seems like the Contact ID is being treated as a number instead of a string or GUID format, which is causing the error. To resolve this issue, please make sure you’re passing the Contact ID as a string or in GUID format. If you can share the part of your Pipedream workflow where you’re setting the Contact ID, I can help you identify the specific issue and suggest a solution.

I think it’s because the prop Line Items expect json, but you put in the steps.trigger.event.title which is a string.

, I think you can click into the link below the LineItem description to see the expected format, then you can construct the object and put it in the custom expression

here’s a screenshot of my workflow and here’s how I am adding cantact ID in a number format - Screenshot by Lightshot

Based on the screenshot you provided, it seems like you’re passing the Contact ID as a number. However, Xero expects the Contact ID to be in GUID format, which is a string. To fix this issue, you should update your workflow to pass the Contact ID as a string instead of a number. Make sure the Contact ID is in the correct GUID format, like this: "123e4567-e89b-12d3-a456-426614174000" (example GUID). Once you’ve updated the Contact ID to be a string in GUID format, try running your workflow again and see if the error is resolved.

How can I find the Contact ID in GUID format ?

To find the Contact ID in GUID format, you’ll need to fetch the contact information from Xero using their API or by checking the contact details within the Xero platform. If you’re using Pipedream, you can use the Xero API to fetch contacts and extract the Contact ID in GUID format. Once you have the Contact ID, you can use it in your Pipedream workflow to create a sales invoice. If you need help with fetching contacts from Xero using Pipedream, please let me know and I can guide you through the process.

Yes please help me with fetching contacts from Xero using Pipedream.

To fetch contacts from Xero using Pipedream, you can follow these steps: 1. Create a new Pipedream workflow. 2. Add a new action step by clicking the “+” button. 3. Search for “Xero” in the app search bar. 4. Select the “Xero Accounting API - List Contacts” action. 5. Connect your Xero account by following the on-screen instructions. 6. Configure any filters or options as needed and click “Deploy” to save the action. Now, whenever the workflow is triggered, it will fetch contacts from Xero using the “List Contacts” action. You can then use the output of this action in subsequent steps of your workflow to process the contacts as needed. If you need further assistance or have any questions, feel free to ask.

How to get Line_items parameter from Xero ?

To get the Line_items parameter from Xero, you’ll need to fetch the required data from Xero using their API. In Pipedream, you can use the Xero Accounting API actions to fetch the necessary data and extract the Line_items parameter. Here’s a high-level process to fetch Line_items from Xero using Pipedream: 1. Create a new Pipedream workflow. 2. Add a new action step by clicking the “+” button. 3. Search for “Xero” in the app search bar. 4. Select the appropriate Xero Accounting API action that returns the Line_items data (e.g., “List Invoices” or “Get Invoice”). 5. Connect your Xero account by following the on-screen instructions. 6. Configure any filters or options as needed and click “Deploy” to save the action. Once you’ve fetched the data containing the Line_items parameter, you can use the output of this action in subsequent steps of your workflow to process the Line_items as needed. If you need further assistance or have any questions, feel free to ask.

I got an Invoice from Xero. But Line_items property is null like this - Line_items=[0]. So, what to do now?

If the Line_items property is null or empty in the invoice you fetched from Xero, it means that there are no line items associated with that invoice. To add line items to the invoice, you’ll need to update the invoice in Xero with the desired line items. To do this in Pipedream, you can use the “Xero Accounting API - Update Invoice” action. You’ll need to provide the Invoice ID of the invoice you want to update and the new Line_items data in the required format. 1. Add a new action step in your Pipedream workflow. 2. Search for “Xero” in the app search bar. 3. Select the “Xero Accounting API - Update Invoice” action. 4. Connect your Xero account by following the on-screen instructions. 5. Provide the Invoice ID and the new Line_items data in the required format. 6. Click “Deploy” to save the action. Once you’ve updated the invoice with the new Line_items data, you can fetch the invoice again to verify that the Line_items property has been updated. If you need help with the Line_items data format or have any questions, feel free to ask.