Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

invoice does not return url

Started by Alex French -   in Wrapper libraries

I would like to get the URL of the invoice after creating it, so that I can include the link in an email I will send to the customer.

However, when I create the invoice and send to Xero, the invoice URL field is not assigned by Xero.
There are no errors returned.

Is there something else I need to do to get the URL?

here's my code

Public Function SendToXero(invoice As Invoice) As Invoice

' POST the invoice to Xero and return the invoice number allocated by Xero
Dim MyConsumer As Consumer = New Consumer("myconsumerkey", "myconsumersecretkey")

Dim ConsumerSecret As String = "myconsumersecretkey"
Dim ConsumerKey As String = "myconsumerkey"
Dim APIendpoint As String = "https://api.xero.com/api.xro/2.0/"
Dim PFXPath As String = "captioningstudio.com-wildcard.pfx"

Dim Credentials As XeroCredentials = New XeroCredentials
With Credentials
.PFXPath = PFXPath
.APIEndPoint = APIendpoint
.ConsumerSecret = ConsumerSecret
.ConsumerKey = ConsumerKey
End With

Dim XeroAPIConnection As XeroCoreApi = GetXeroPrivateAPIConnection(Credentials)
Dim Result As Invoice
Try
Result = XeroAPIConnection.Invoices.Create(invoice)
Catch ex As Xero.Api.Infrastructure.Exceptions.ValidationException
Dim ErrMessage As String = ""
For n = 0 To ex.ValidationErrors.Count - 1
ErrMessage = ErrMessage & " " & ex.ValidationErrors.Item(n).Message
Next
MsgBox(ErrMessage)
End Try

Return Result

End Function

Invoice = SendToXero(Invoice)
Dim InvoiceId As String = Invoice.Id.ToString
Dim InvoiceURL As String = Invoice.Url
Hi Alex,

Are you referring to the Online Invoicing URL, the link that is included in an email sent to a customer from an invoice in Xero? If so, you need to make a dedicated call to retrieve this, it's not returned in the response when creating the Invoice. Take a look at our docs here

Let me know if thats what you're after?
 

James Coleman (Community Manager)  

Hi James

Thanks so much. Yes, that's what I'm after. How do I get that using the .NET wrapper for the API?
 

Alex French  

Hi Alex,

Unfortunately we've not added it to the wrapper yet, but we're on the case and it should be available later this week. Keep an eye on the releases page but I'll try and let you know when it's ready too.

James
 

James Coleman (Community Manager)  

OnlineInvoiceUrl functionality now available in the Xero-Net wrapper
 

Xero API (Community Manager)  

I've tried retrieving an ACCPAY invoice this way and receive the 'Resource cannot be found' message. Should this functionality be working for payable as well as receivables?

Thanks
Richard
 

Richard Freeman  

Hi Richard, no it's only available for ACCREC sales invoices. It's the URL that is supplied in the email from a sales invoice that allows the customer to view (and pay) the invoice online.
 

James Coleman (Community Manager)  

Ok Thanks James.

I just realised I can get the attachments through the attachments endpoint which serves my need.
 

Richard Freeman  

Hi,

Can you retrieve the OnlineInvoiceURL for a draft invoice?
 

Alan Baird  

Hi Alan,

No it's not possible, we call this out in our docs here.

James
 

James Coleman (Community Manager)