I’ve got a zap that creates a Xero invoice from a fluent form webhook. It works perfectly except for the address which doesn’t populate on the invoice.
I either need a way to add it to the invoice myself or set the address as default for billing when the contact is created.
Actually, I am Posting an Invoice to zero with some address and It is successfully showing on the the preview Invoice in XERO but when i tries to Update the address and update the Line Items, amount ,price etc, these things are updating fine but address is remaining the Same , even though i have debugged JSON weare sending and It has updated Address but in XERO invoice preview it is not updatin for that Invoice
//code
#region Xero Post Invoice Start // post to Xero try { var invoice = new XeroApi.Model.Invoice(); invoice.Type = "ACCREC"; invoice.Date = Convert.ToDateTime(objPostingMasterProp.SaleDate); invoice.DueDate = Convert.ToDateTime(objPostingMasterProp.DueDate); invoice.LineAmountTypes = objPostingMasterProp.LineAmountTypes == "Exclusive" ? XeroApi.Model.LineAmountType.Exclusive : objPostingMasterProp.LineAmountTypes == "Inclusive" ? XeroApi.Model.LineAmountType.Inclusive : XeroApi.Model.LineAmountType.NoTax; invoice.Status = objPostingMasterProp.InvoiceType; invoice.Reference = objPostingMasterProp.Reference;
// contact var contact = new XeroApi.Model.Contact(); contact.Name = objPostingMasterProp.ContactName;
var addresses = new XeroApi.Model.Addresses(); var address = new XeroApi.Model.Address(); address.AddressType = "POBOX"; address.AddressLine1 = objPostingMasterProp.BillAddress; address.City = objPostingMasterProp.BillCity; address.Region = objPostingMasterProp.BillState; address.PostalCode = objPostingMasterProp.BillPostalCode; address.Country = objPostingMasterProp.BillCountry; addresses.Add(address); contact.Addresses = addresses;
// other part
RestSharp.RestClient client = null; if (updatePostedInvoice) //needToUpdateInvoice { var invoiceHeaderData = new InvoiceHeaderBal().GetInvoiceHeaderById(Convert.ToInt64(headerId), isSplitedInvoice); //var guid = "ac603e53-23fe-4cad-9d81-e3e86dd1b17f"; if (!string.IsNullOrEmpty(invoiceHeaderData.APIInvoiceGUID)) { client = new RestSharp.RestClient($"https://api.xero.com/api.xro/2.0/Invoices/{invoiceHeaderData.APIInvoiceGUID}"); } } else { client = new RestSharp.RestClient("https://api.xero.com/api.xro/2.0/Invoices"); } client.Timeout = -1; var _AccessToken = GetTokenDeatilsOAuth(companyId, companyUserId, apiCompanyId, oAuthSession); // var _TenantId = GetDetailbyTenantId(companyId, companyUserId, apiCompanyId);// (_AccessToken); //added by deepak for Oauth 2.0 api call var request = new RestSharp.RestRequest(RestSharp.Method.POST); request.AddHeader("Authorization", "Bearer " + _AccessToken); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); request.AddHeader("Accept", "application/json"); request.AddHeader("xero-tenant-id", "" + _TenantId + ""); request.AddParameter("application/json", json, RestSharp.ParameterType.RequestBody); //request.AddParameter("text/xml;charset=utf-8", l_PostingXML, ParameterType.RequestBody); RestSharp.IRestResponse getRequest = client.Execute(request); RootModel postedInvoice = new RootModel(); ErrorRootInvoice errormodel = new ErrorRootInvoice(); if (getRequest.StatusCode.ToString() == "OK") { postedInvoice = JsonConvert.DeserializeObject<RootModel>(getRequest.Content);
Seems like you aren’t using the Xero app’s standard actions to create or update the invoices. Are you using a Code by Zapier action instead?
Either way, Troy's comment about invoices defaulting to use the postal address of the contact would likely still apply here, so that could be why it's not updating the address on the invoice. You might need to first update the contact's postal address before creating the invoice.