Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Get salesInvoice pdfDocument

Posted on by 224

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

Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,864 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 224 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,744 Moderator on at
    RE: Get salesInvoice pdfDocument

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

  • Juliem Profile Picture
    Juliem 224 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,744 Moderator 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 224 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,155 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 224 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,423 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans