'How to post cXML invoice with attachments in Coupa?

Coupa has introduced this new functionality of including attachments in cXML invoices. The only documentation (That I am aware of) says that include code (mentioned below) in CXML invoice file.

Coupa Documentation:

Screenshot from Coupa Documentation

Can anyone please help me understanding how can I use this documentation in sending a cXML invoice? Any other help on including attachments on cXML invoice (for Coupa) will be appreciated.

Thanks in advance



Solution 1:[1]

Correct, R18 allows you to attach file(s) at the time you post your InvoiceDetailRequest cxml. Before R18, you would attach through a 2 part post via a Coupa API key. Starting with R18, there's no API key and you use the header . Below is how you do it. I'll monitor this page in case you have further clarifying questions.

1--You must indicate MIME multipart media type in your Content-ID header. This will trigger our parser to retrieve the attachment.

example: Content-type: multipart/related

2--You must pass the attribute in the element. Attachment data can be a url or a content id (cid) to a file on your server. If doing cid, the file must reside on the same folder structure on your server as your InvoiceDetailRequest doc. In the below example, we're attaching 2 files, a file and a url.

example:

<Comments>
<Attachment><URL>cid:test.pdf</URL></Attachment>
<Attachment><URL>url</URL></Attachment>
</Comments>
</InvoiceDetailRequestHeader>

For more details, see pages 51 & 69 on cxml.org.

Solution 2:[2]

Example

------=_Part_1_11.11

Content-Type: text/xml; charset=UTF-8

Content-ID:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.020/InvoiceDetail.dtd">
<cXML version="1.2.020" xml:lang="en-US" timestamp="2018-03-08T8:48:54-08:00" payloadID="2018-03-08T8:48:54-08:00">
    <Header>
        <From>
            <Credential domain="duns">
                <Identity>xxx</Identity>
            </Credential>
        </From>
        <To>
            <Credential domain="duns">
                <Identity>yyy</Identity>
            </Credential>
        </To>
        <Sender>
            <Credential domain="duns">
                <Identity>xxx</Identity>
                <SharedSecret>none</SharedSecret>
            </Credential>
            <UserAgent>Coupa Procurement 1.0</UserAgent>
        </Sender>
    </Header>
    <Request deploymentMode="production">
        <InvoiceDetailRequest>
            <InvoiceDetailRequestHeader invoiceDate="2018-03-08T8:48:54-08:00" operation="new" purpose="standard" invoiceOrigin="supplier" invoiceID="COUPATEST">
                <InvoiceDetailHeaderIndicator />
                <InvoiceDetailLineIndicator isAccountingInLine="yes" />
                <PaymentTerm payInNumberOfDays="30" />
                <Comments>
                    <Attachment>
                        <URL>cid:invoice.pdf</URL>
                    </Attachment>
                </Comments>
            </InvoiceDetailRequestHeader>
            <InvoiceDetailOrder>
                <InvoiceDetailOrderInfo>
                    <OrderReference>
                        <DocumentReference payloadID="19897" />
                    </OrderReference>
                </InvoiceDetailOrderInfo>
                <InvoiceDetailItem quantity="1.0" invoiceLineNumber="1">
                    <UnitOfMeasure>EA</UnitOfMeasure>
                    <UnitPrice>
                        <Money currency="USD">1.00</Money>
                    </UnitPrice>
                    <InvoiceDetailItemReference lineNumber="1">
                        <ItemID>
                            <SupplierPartID />
                            <SupplierPartAuxiliaryID />
                        </ItemID>
                        <Description xml:lang="en-US">Pencil, Blue, Fine Fonts</Description>
                    </InvoiceDetailItemReference>
                    <SubtotalAmount>
                        <Money currency="USD">1.00</Money>
                    </SubtotalAmount>
                </InvoiceDetailItem>
            </InvoiceDetailOrder>
            <InvoiceDetailSummary>
                <SubtotalAmount>
                    <Money currency="USD">1.00</Money>
                </SubtotalAmount>
                <Tax>
                    <Money currency="USD">0</Money>
                    <Description xml:lang="en-US" />
                    <TaxDetail purpose="tax" category="USD" percentageRate="0" taxPointDate="2018-03-08T8:48:54-08:00">
                        <TaxableAmount>
                            <Money currency="USD">1.00</Money>
                        </TaxableAmount>
                        <TaxAmount>
                            <Money currency="USD">0</Money>
                        </TaxAmount>
                        <TaxLocation xml:lang="en">USD</TaxLocation>
                    </TaxDetail>
                </Tax>
                <NetAmount>
                    <Money currency="USD">1.00</Money>
                </NetAmount>
            </InvoiceDetailSummary>
        </InvoiceDetailRequest>
    </Request>
</cXML>

------=_Part_2_22.22

Content-Type: application/pdf

Content-transfer-encoding: urlencoded

Content-Disposition: attachment; filename=invoice.pdf

Content-ID:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.020/InvoiceDetail.dtd">
<cXML version="1.2.020" xml:lang="en-US" timestamp="2018-03-08T8:48:54-08:00" payloadID="2018-03-08T8:48:54-08:00">
    <Header>
        <From>
            <Credential domain="duns">
                <Identity>xxx</Identity>
            </Credential>
        </From>
        <To>
            <Credential domain="duns">
                <Identity>yyy</Identity>
            </Credential>
        </To>
        <Sender>
            <Credential domain="duns">
                <Identity>xxx</Identity>
                <SharedSecret>none</SharedSecret>
            </Credential>
            <UserAgent>Coupa Procurement 1.0</UserAgent>
        </Sender>
    </Header>
    <Request deploymentMode="production">
        <InvoiceDetailRequest>
            <InvoiceDetailRequestHeader invoiceDate="2018-03-08T8:48:54-08:00" operation="new" purpose="standard" invoiceOrigin="supplier" invoiceID="COUPATEST">
                <InvoiceDetailHeaderIndicator />
                <InvoiceDetailLineIndicator isAccountingInLine="yes" />
                <PaymentTerm payInNumberOfDays="30" />
                <Comments>
                    <Attachment>
                        <URL>cid:invoice.pdf</URL>
                    </Attachment>
                </Comments>
            </InvoiceDetailRequestHeader>
            <InvoiceDetailOrder>
                <InvoiceDetailOrderInfo>
                    <OrderReference>
                        <DocumentReference payloadID="19897" />
                    </OrderReference>
                </InvoiceDetailOrderInfo>
                <InvoiceDetailItem quantity="1.0" invoiceLineNumber="1">
                    <UnitOfMeasure>EA</UnitOfMeasure>
                    <UnitPrice>
                        <Money currency="USD">1.00</Money>
                    </UnitPrice>
                    <InvoiceDetailItemReference lineNumber="1">
                        <ItemID>
                            <SupplierPartID />
                            <SupplierPartAuxiliaryID />
                        </ItemID>
                        <Description xml:lang="en-US">Pencil, Blue, Fine Fonts</Description>
                    </InvoiceDetailItemReference>
                    <SubtotalAmount>
                        <Money currency="USD">1.00</Money>
                    </SubtotalAmount>
                </InvoiceDetailItem>
            </InvoiceDetailOrder>
            <InvoiceDetailSummary>
                <SubtotalAmount>
                    <Money currency="USD">1.00</Money>
                </SubtotalAmount>
                <Tax>
                    <Money currency="USD">0</Money>
                    <Description xml:lang="en-US" />
                    <TaxDetail purpose="tax" category="USD" percentageRate="0" taxPointDate="2018-03-08T8:48:54-08:00">
                        <TaxableAmount>
                            <Money currency="USD">1.00</Money>
                        </TaxableAmount>
                        <TaxAmount>
                            <Money currency="USD">0</Money>
                        </TaxAmount>
                        <TaxLocation xml:lang="en">USD</TaxLocation>
                    </TaxDetail>
                </Tax>
                <NetAmount>
                    <Money currency="USD">1.00</Money>
                </NetAmount>
            </InvoiceDetailSummary>
        </InvoiceDetailRequest>
    </Request>
</cXML>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Phannga Pathammavong
Solution 2 Phannga Pathammavong