Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Get salesInvoice pdfDocument

(0) ShareShare
ReportReport
Posted on by 231

Hi,

We are trying to follow the steps described here : https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_salesquote_pdfdocument to retrieve the PDF document for a sales Invoice

However, we are getting the following error message: The URI segment 'pdfDocument' is invalid after the segment 'salesInvoice({id})

The document has a PDF attached. It was attached by the Attached as PDF action on the sales invoice. I took a look at the Attachment Entity Buffer table and it's empty. What are we missing?

Any help would be appreciated

Thanks

-Julie

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,036 Super User 2024 Season 2 on at
    RE: Get salesInvoice pdfDocument

    Hi, I think it's because the page is set with the following properties.

    SourceTableTemporary = true;

    pastedimage1643939238496v1.png

    And you can  publish Document Attachment Details (1173, List) or a new page created to webservice and try it again.

    Hope this will help.

    Thanks.

    ZHU

  • Juliem Profile Picture
    Juliem 231 on at
    RE: Get salesInvoice pdfDocument

    The object name is salesInvoices, you are correct but the documentation does not. What is important is the service name of your web service, if I'm not mistaken. I changed it, for the sake of it, but it doesn't change anything to the end result

    GET businesscentralPrefix/api/v2.0/companies({id})/salesInvoices({salesInvoiceId}) does work

    GET businesscentralPrefix/api/v2.0/companies({id})/salesInvoices({salesInvoiceId})/pdfDocument does not

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Get salesInvoice pdfDocument

    As i said i think it says salesInvoices and not salesInvoice.

  • Juliem Profile Picture
    Juliem 231 on at
    RE: Get salesInvoice pdfDocument

    The documentation says:

    GET businesscentralPrefix/api/v2.0/companies({id})/salesInvoice({salesInvoiceId})/pdfDocument

    If I understand properly, this needs to match with the web service name.

    if we try GET businesscentralPrefix/api/v2.0/companies({id})/salesInvoice({salesInvoiceId}) without the /pdfDocument at the end, we get the data from that salesInvoice

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Get salesInvoice pdfDocument

    According to the documentation it should be  'salesInvoices({id}) and  not 'salesInvoice({id}) as you wrote that you are using.

    Maybe that is causing this?

  • Juliem Profile Picture
    Juliem 231 on at
    RE: Get salesInvoice pdfDocument

    I do understand that we will need development. But I thought that using this GET businesscentralPrefix/api/v2.0/companies({id})/salesInvoice({salesInvoiceId})/pdfDocument would at least give us the 200 OK response with the link to the PDF as mentioned on the link. But we are getting an error message instead

  • Suggested answer
    JAngle Profile Picture
    JAngle 33,159 on at
    RE: Get salesInvoice pdfDocument

    The pdfdocument endpoint is just pulling a copy of the documents report layout as a pdf file. The attachment table doesn’t have an api. The one in the documentation is just the incoming documents table. Your requirement would require development

  • Juliem Profile Picture
    Juliem 231 on at
    RE: Get salesInvoice pdfDocument

    The first step would be to actually see if there is one attached

    Then we would like to use the /content

  • Dallefeld Profile Picture
    Dallefeld 11,425 User Group Leader on at
    RE: Get salesInvoice pdfDocument

    What are you trying to do with the attached pdf? Are you trying to resend?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans