0

I have been posting invoices generated in NetSuite to the Ariba Supplier Network via cXML. Recently, one of our customers changed to require a pdf attachment accompany all invoice submissions.

I can get the URL of the invoice PDF from a NetSuite saved search. Can I pass this URL in the attachment element? Do I also need to use a MIME envelope to create the attachment in Ariba?

This is what I am trying to pass with POSTMAN. I am getting the following status back.

The document could not be parsed: Content is not allowed in prolog. (line 1, column 1) [ANCLS-125007011]

Content-Type: multipart/mixed; boundary=RJM4809370DO2978413
--RJM4809370DO2978413
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.035/InvoiceDetail.dtd">
<cXML payloadID="IN.DO2978413.20190309110306" 
            <InvoiceDetailRequestHeader invoiceDate="2019-03-09T11:32:55-05:00" 
                <Extrinsic name="invoicePDF">
                    <Attachment>
                        <URL>cid:system.na2.netsuite.com/core/media/media.nl?id=4417380&c=XXXXXX&h=7528d4b175c15c719e89&_xt=.pdf</URL>
                    </Attachment>
                </Extrinsic>
            </InvoiceDetailRequestHeader>
............
</cXML>
--RJM4809370DO2978413
Content-Type: application/pdf
Content-ID:<system.na2.netsuite.com/core/media/media.nl?id=XXXXXX&c=4086366&h=7528d4b175c15c719e89&_xt=.pdf>
Content-Disposition: attachment; filename=11315307.PDF

--RJM4809370DO2978413--

Here is the raw request.

POST
https://service.ariba.com/service/transaction/cxml.asp
12:46:10.923

Request Headers:
Content-Type:"Multipart/mixed; boundary="RJM4809370DO2978413";type="text/xml""
cache-control:"no-cache"
Postman-Token:"973410c7-0db8-4140-822c-4ac4dffe3dcd"
User-Agent:"PostmanRuntime/7.6.1"
Accept:"*/*"
Host:"service.ariba.com"
accept-encoding:"gzip, deflate"
content-length:7844
Request Body:"--RJM4809370DO2978413
 Content-Type: text/xml; charset=UTF-8
 Content-Disposition: attachment
 Content-ID: 

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.035/InvoiceDetail.dtd">
 <cXML payloadID="IN.DO2978413.20190311140375" timestamp="2019-03-11T14:34:19.758Z">
 <Header>
 <From>
 <Credential domain="AribaNetworkUserID">
 <Identity>ariba@XXXXXXX.com</Identity>
 </Credential>
 </From>
 <To>
 <Credential domain="NetworkID">
 <Identity>XXXXXXXXXX</Identity>
 </Credential>
 </To>
 <Sender>
 <Credential domain="AribaNetworkUserID">
 <Identity>ariba@XXXXXX.com</Identity>
 <SharedSecret>XXXXXXXXX</SharedSecret>
 </Credential>
 <UserAgent>Celigo Invoice Request</UserAgent>
 </Sender>
 </Header>
 <Request deploymentMode="production">
 <InvoiceDetailRequest>
 <InvoiceDetailRequestHeader invoiceDate="2019-03-11T14:34:19-05:00" invoiceID="11315307" invoiceOrigin="supplier" operation="new" purpose="standard">
 <InvoiceDetailHeaderIndicator/>
 <InvoiceDetailLineIndicator isAccountingInLine="yes" isTaxInLine="yes" />
 <InvoicePartner>
 <Contact role="remitTo">
 <Name xml:lang="en-US">XXXXXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXXX</Street>
 <Street></Street>
 <Street></Street>
 <City>XXXXXXXX</City>
 <State>XX</State>
 <PostalCode>XXXXXX</PostalCode>
 <Country isoCountryCode="">United States</Country>
 </PostalAddress>
 </Contact>
 <IdReference domain="supplierTaxID" identifier="XXXXXXXX"/>
 </InvoicePartner>
 <InvoicePartner>
 <Contact role="billTo">
 <Name xml:lang="en-US">XXXXXXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXXXXX</Street>
 <Street>XXXXXXXX</Street>
 <City>XXXXXX</City>
 <State>XXX</State>
 <PostalCode>XXXXX</PostalCode>
 <Country isoCountryCode="US">United States</Country>
 </PostalAddress>
 </Contact>
 </InvoicePartner>
 <InvoicePartner>
 <Contact role="soldTo">
 <Name xml:lang="en-US">XXXXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXXXX</Street>
 <Street></Street>
 <City>XXXXXX</City>
 <State>XX</State>
 <PostalCode>XXXXXXXX</PostalCode>
 <Country isoCountryCode="US">United States</Country>
 </PostalAddress>
 </Contact>
 </InvoicePartner>
 <InvoiceDetailShipping>
 <Contact role="shipFrom">
 <Name xml:lang="en-US">XXXXXX</Name>
 <PostalAddress>
 <Street>XXXXXX</Street>
 <Street></Street>
 <Street></Street>
 <City>XXXXXXX</City>
 <State>XXX</State>
 <PostalCode>XXXXXX</PostalCode>
 <Country isoCountryCode="">United States</Country>
 </PostalAddress>
 </Contact>
 <Contact role="shipTo">
 <Name xml:lang="en-US">XXX</Name>
 <PostalAddress>
 <Street>XXXXX</Street>
 <Street></Street>
 <Street></Street>
 <City>XXXXXX</City>
 <State>XXXXXX</State>
 <PostalCode>XXXXXX</PostalCode>
 <Country isoCountryCode=""></Country>
 </PostalAddress>
 </Contact>
 </InvoiceDetailShipping>
 <Extrinsic name="invoicePDF">
 <Attachment>
 <URL>cid:https://system.na2.netsuite.com/core/media/media.nl?id=XXXXXXXXXXXh=7528d4b175c15c719e89&_xt=.pdf</URL>
 </Attachment>
 </Extrinsic>
 </InvoiceDetailRequestHeader>
 <InvoiceDetailOrder>
 <InvoiceDetailOrderInfo>
 <OrderReference orderID="DO2978413">
 <DocumentReference payloadID="1551826564527.841867458.000002574@Hdw2llNIeZN+Ro4D2ATtzEA2KaI&#x3D;"/>
 </OrderReference>
 </InvoiceDetailOrderInfo> 
 <InvoiceDetailItem invoiceLineNumber="1" quantity="2">
 <UnitOfMeasure>EA</UnitOfMeasure>
 <UnitPrice>
 <Money currency="USD">1000.00</Money>
 </UnitPrice>
 <InvoiceDetailItemReference lineNumber="1">
 <ItemID>
 <SupplierPartID>XXXXXX</SupplierPartID>
 </ItemID>
 <Description xml:lang="en">XXXXXX</Description>
 </InvoiceDetailItemReference>
 <Extrinsic name="punchinItemFromCatalog">no</Extrinsic>
 </InvoiceDetailItem> 
 </InvoiceDetailOrder>
 <InvoiceDetailSummary>
 <SubtotalAmount>
 <Money currency="USD">2000</Money>
 </SubtotalAmount>
 <Tax>
 <Money currency="USD">0</Money>
 <Description xml:lang="en-US"/>

 <TaxDetail category="sales">
 <TaxableAmount>
 <Money currency="USD">2000</Money>
 </TaxableAmount>
 <TaxAmount>
 <Money currency="USD">0</Money>
 </TaxAmount>
 <Description xml:lang="en">Sales tax</Description>
 </TaxDetail>
 </Tax>
 <ShippingAmount>
 <Money currency="USD">332</Money>
 </ShippingAmount>
 <GrossAmount>
 <Money currency="USD">2332</Money>
 </GrossAmount>
 <NetAmount>
 <Money currency="USD">2332</Money>
 </NetAmount>

 <DueAmount>
 <Money currency="USD">2332</Money>
 </DueAmount>
 </InvoiceDetailSummary>
 </InvoiceDetailRequest>
 </Request>
 </cXML>
 --RJM4809370DO2978413
 Content-Type: application/pdf
 Content-ID: <https://system.na2.netsuite.com/core/media/media.nl?id=XXXXXXXXXXXX&h=7528d4b175c15c719e89&_xt=.pdf>
 Content-Disposition: attachment; filename=11315307.PDF

 --RJM4809370DO2978413--
 "
Response Headers:
Date:"Mon, 11 Mar 2019 16:46:11 GMT"
Server:"Apache"
Content-Length:"350"
Content-Encoding:"gzip"
Vary:"User-Agent"
Keep-Alive:"timeout=15, max=100"
Connection:"Keep-Alive"
Content-Type:"text/html; charset=UTF-8"
Strict-Transport-Security:"max-age=31536000"

Response Body:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.041/cXML.dtd">

<cXML timestamp="2019-03-11T09:46:11-07:00" payloadID="1552322771952-2933358902296997425@10.162.97.171">

    <Response>

        <Status code="500" text="Internal Server Error">ANERR-110000000000000000345730259:can not have stream of negative length(start 7610, end 7585, original length 7844)</Status>

    </Response>
</cXML>
RJM1212016
  • 1
  • 1
  • 2

2 Answers2

0

The cXML standard specifies attachment handling via MIME envelope.

One MIME part is a regular cXML message which contains an Attachment element as a reference to the second MIME part's Content-ID header.

For further details see section 2.1.5 in the cXML Reference Guide.

Yuri
  • 4,254
  • 1
  • 29
  • 46
  • I tried following the cXML reference guide to the best of my abilities. I added what I am trying to post via POSTMAN and the status I am getting back. – RJM1212016 Mar 10 '19 at 16:55
  • The error says it expected a XML declaration but here wasn't any. Can you check the actual RAW form of HTTP request the POSTMAN generates? It not I would suggest using `curl` instead. It got great visibility and support. A similar case to yours is for instance: https://stackoverflow.com/questions/19178813/sending-multipart-mixed-content-with-postman-chrome-extension – Yuri Mar 10 '19 at 19:39
  • I set the Header Content-Type Multipart/mixed; boundary=RJM4809370DO2978413 I now receive "Value found: "500". Response body: ANERR-110000000000000000345676037:can not have stream of negative length(start 7481, end 7458, original length 7742)" – RJM1212016 Mar 11 '19 at 12:26
  • @RJM1212016 In order to help you, I need to see a whole HTTP request. That means using `curl -v` or somehow displaying a RAW request in POSTMAN. – Yuri Mar 11 '19 at 15:32
  • Added the raw request. I removed any proprietary information. – RJM1212016 Mar 11 '19 at 17:53
  • `Content-Type:"Multipart/mixed; boundary="RJM4809370DO2978413";type="text/xml""` Try to remove the `type=` part. – Yuri Mar 12 '19 at 13:04
  • I then get the following: The document could not be parsed: The markup in the document following the root element must be well-formed. (line 10, column 19) [ANCLS-125000009] – RJM1212016 Mar 12 '19 at 15:22
  • It says your XML part is malformed. Copy&paste the content to a XML editor and check it. In your example the `` is malformed due to `&`. – Yuri Mar 12 '19 at 15:50
  • are you referring to my attachment URL? That is how NetSuite is producing the link to the invoice. I am trying to pass that link to Ariba as an attachment. Can I do that or do I need to pass it as BLOB? – RJM1212016 Mar 12 '19 at 16:32
0

Can you escape the & as Yuri suggests? My reputation points only allow for me to submit as an answer not to comment:

    cid:https://system.na2.netsuite.com/core/media/media.nl?id=XXXXXXXXXXXh=7528d4b175c15c719e89&amp;_xt=.pdf