DocuSign API using XML to move Envelope to Recycle Bin - docusignapi

I'm having issues trying to move a completed envelope into the deleted bin in DocuSign using the REST API. The error I am getting is:
<errorDetails xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<errorCode>INVALID_REQUEST_BODY</errorCode>
<message>The request body is missing or improperly formatted. <envelopeMoveRequest xmlns=''> was not expected.</message>
</errorDetails>
Here is the API call I make:
Address: https://www.docusign.net/restapi/v2/accounts/{accountid}/folders/recyclebin Http-Method: PUT
Content-Type: application/xml
Headers: {Content-Type=[application/xml], Accept=[application/xml], X-DocuSign-Authentication=[{"Username":"username","Password":"password","IntegratorKey":"integrator key"}], Context-Length=[31274]}
Payload:
<?xml version="1.0" encoding="UTF-8"?>
<envelopeMoveRequest xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<envelopeIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:string>EnvelopeId</d2p1:string>
</envelopeIds>
<fromFolderId/>
</envelopeMoveRequest>
I could use some help figuring out how my API call is wrong.

The following just worked for me. Make sure you are not copy/pasting any hidden or extra characters as well:
<envelopeMoveRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.docusign.com/restapi">
<envelopeIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:string>828a593e-10ae-4e54-bccc-66b5e66a5e81</d2p1:string>
</envelopeIds>
</envelopeMoveRequest>

Usually the corresponding XML for DocuSign requests (when compared to the JSON equivalent) has extra nodes representing individual elements of a collection or array. So in this case try adding an individual node for each envelopeId.
Right now you have:
<envelopeIds>EnvelopeId</envelopeIds>
Try changing to this:
<envelopeIds>
<envelopeId>EnvelopeId</envelopeId>
</envelopeIds>

Related

How to parse and edit XML in TypeScript without converting to JSON

I need to repair an XML file in TypeScript and I cannot find any info on it, since everyone who posts something like this has different needs. I'd like to be pointed in the right direction here.
I have an XML request as shown below. It is autogenerated by node-soap when given JSON. Using the WSDL, node-soap attempts to fill in the namespace prefixes for each property. The problem is, it gets them wrong a lot.
In this example below, q106 should be replaced with hep3.
<soap:Envelope q15="some-good-url" q106="some-good-url-1" q98-"some-good-url-2>
...
<q98:SalesOrderAuditInfo>
<q15:ConfirmedBy xsi:nil="true"></q15:ConfirmedBy>
<q15:ConfirmedDate>0001-01-01T00:00:00</q15:ConfirmedDate>
<q15:CreatedBy>
<q106:ID>103</q106:ID>
<q106:Value>System, System</q106:Value>
</q15:CreatedBy>
<q15:CreatedDate>2022-10-26T00:43:13.413</q15:CreatedDate>
<q15:SalesOrderType>Standard</q15:SalesOrderType>
</q98:SalesOrderAuditInfo>
I know which namespace prefixes are bad because I have a sample request that was supplied to me. It's just XML. It looks like this:
<soap:Envelope hep="some-good-url" hep1="some-good-url-1" hep2-"some-good-url-2 hep3="some-good-url-3">
...
<hep2:SalesOrderAuditInfo>
<hep:ConfirmedBy xsi:nil="true"></hep:ConfirmedBy>
<hep:ConfirmedBy:ConfirmedDate>0</hep:ConfirmedByConfirmedDate>
<hep:CreatedBy>
<hep3:ID>103</hep3:ID>
<hep3:Value>System, System</hep3:Value>
</hep:CreatedBy>
<hep:CreatedDate>0</hep:CreatedDate>
<hep:SalesOrderType>Standard</hep:SalesOrderType>
</hep2:SalesOrderAuditInfo>
Here is the part that really matters. The Sample Request is the entire possible request body. The supplied request (with incorrect namespaces) is a subset of the sample request. I need to loop through each of the elements in the supplied request, and check to make sure the URL of that element matches the URL of the respective element in the sample request.
So in this example, loop through each element of supplied request. Start with SalesOrderAuditInfo. It's namespace URL is some-good-url-2. If we check the Sample Request, we can see that SalesOrderAuditInfo also corresponds to some-good-url-2.
Continue until we hit the ID tag. This has a namespace set to some-good-url-1. If we check the Same ID (inside of CreatedBy, inside of SalesOrderAuditInfo), we can see the namespace should actually be set to some-good-url-3. So we replace q106 with hep3.
I also need to take all of the namespaces defined in the Sample Request Envelope and move them into the supplied request envelope so that this new hep3 will be defined.
At this point, I need to edit the namespace prefix. In this example, q106:ID would be replaced be the string hep3:ID. Same with all of the closing tags.
Which library can I use to accomplish this in XML? Is anyone familiar with node-soap screwing these namespaces up and know of any fix?
I am using node-soap v0.43

NodeJS Amazon AWS Submit Feed Generic Error

I am trying to submit a product feed to AWS and I keep getting a generic error related to the XML I am sending
I have gone through all the .xsd files and come up what I believe to be correct xml but apparently not :(
The Error
{
"MessageID": "1",
"ResultCode": "Error",
"ResultMessageCode": "25",
"ResultDescription": "We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed."
}
How I am creating the content
const getContent = (upc) => `<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>${process.env.MERCHANT_ID}</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>${upc}</SKU>
</Product>
</Message>
</AmazonEnvelope>`
Turns out this just means a value in the xml is malformed. It helped a lot to search the xsd files for the specific variable I was trying to tie a value to and then it provides the restrictions on that value (i.e. AmazonOrderId has a regex validation associated with it that restricts the value to be in the structure of 123-1234567-1234567). After I manually ran through this process for each variable I was able to submit a feed finally but now I have to have an associated OrderAcknowledgement which I am working through.

Cisco CCE: REST Update Request ErrorMessage: The specified URL does not exist

When i try to update agent skillgroup by REST Request i'm getting the following response:
<apiError>
<errorDetail xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="resourceErrorDetail">
<refURL>https://x/unifiedconfig/config/agent/(id)</refURL>
<apiErrors>
<apiError>
<errorMessage>The specified URL does not exist.</errorMessage>
<errorType>notFound.dbData</errorType>
</apiError>
</apiErrors>
</errorDetail>
<errorMessage>There were one or more errors processing the following request: update https://x/unifiedconfig/config/agent/(id)</errorMessage>
<errorType>operation.resourceErrors</errorType>
</apiError>
What i already tooked care:
Names and params all by documentaion
Authorization seccess
I'm getting info but cant update
The problem was Authorization, for update Agent Skillgroup the credential need to be Supervisor of the team you want access to.
Same authorization need to see the following API:
https://{ServerIP}/unifiedconfig/config/skillgroup/
If you can see all skillgroup you would also change agent's skillgroup.
I also mention the syntax:
<operation>
<operationType>update</operationType>
<refURLs>
<refURL>/unifiedconfig/config/agent/5000</refURL>
<refURL>/unifiedconfig/config/agent/5001</refURL>
</refURLs>
<changeSet>
<agent>
<skillGroupsAdded>
<skillGroup>
<refURL>/unifiedconfig/config/skillgroup/6000</refURL>
</skillGroup>
</skillGroupsAdded>
<skillGroupsRemoved>
<skillGroup>
<refURL>/unifiedconfig/config/skillgroup/6001</refURL>
</skillGroup>
</skillGroupsAdded>
</changeSet>
</operation>

GetMyFeesEstimate API Amazon vba

I have a problem getting a reasonable answer from Amazon. The problem is only with GetMyFeesEstimate. The other stuff like GetMyPriceForASIN works. I'm trying to get a response with VBA/Excel.
Example Code from Amazon:
https://mws.amazonservices.de/Products/2011-10-01?
FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId=A1PA6795UKMFR9
&FeesEstimateRequestList.FeesEstimateRequest.1.IdType=ASIN
&FeesEstimateRequestList.FeesEstimateRequest.1.IdValue=3828934897
&FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled=true
&FeesEstimateRequestList.FeesEstimateRequest.1.Identifier=request1
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode=EUR
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount=30.00
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.CurrencyCode=EUR
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.Amount=3.99
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Points.PointsNumber=0
&AWSAccessKeyId=XXXXXXXXXXXXX
&Action=GetMyFeesEstimate
&SellerId=XXXXXXXXXXXXXX
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&Timestamp=2018-01-07T10%3A26%3A27Z&Version=2011-10-01&Signature=bJJJorhyeKwejuddJs6Z%2BVYZZmKtm0CG2GAXTrShyZM%3D
If I try to use this signed request with my data I get the following mistake:
The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
Can someone help me with this?
Here is the Documentation from Amazon.
You haven't shown code on how you are signing the request.
Since you already have been succesful for one API, can you check if you that the decimal values you are using are exactly the same in signing string and POST request?
Sometime excel stores values like 30.0 as 0.3E02 or something like that and this causes the signing string to be different from your post request.
I have used Amazon Scratchpad to create a POST and also to get a guidance on the signing string.
Please go to https://mws.amazonservices.com/scratchpad/index.html
Once you enter the details on the left and click on submit, you can see the Request details and the signing string. If you create the request exactly as specified there and sign exactly as specified there, you shouldnt have a singing issue.
Here is the sample for your request:
POST /Products/2011-10-01?AWSAccessKeyId=
&Action=GetMyFeesEstimate
&SellerId=XXXXXXXXXXXXXX
&SignatureVersion=2
&Timestamp=2018-06-12T04%3A19%3A55Z
&Version=2011-10-01
&Signature=vJLewLVH7FmUD8cpST8dD51GBUJkt6Aj9FADGLoCjNQ%3D
&SignatureMethod=HmacSHA256
&FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId=A1PA6795UKMFR9
&FeesEstimateRequestList.FeesEstimateRequest.1.IdType=ASIN
&FeesEstimateRequestList.FeesEstimateRequest.1.IdValue=3828934897
&FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled=true
&FeesEstimateRequestList.FeesEstimateRequest.1.Identifier=request1
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount=30.00
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode=EUR
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.Amount=3.99
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.CurrencyCode=EUR
&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Points.PointsNumber=0 HTTP/1.1
Host: mws.amazonservices.com
x-amazon-user-agent: AmazonJavascriptScratchpad/1.0 (Language=Javascript)
Content-Type: text/xml
Here is the string to sign.
Note that you have to put CHR(10) for a new line. Do not put VBCRLF in the string.
POST
mws.amazonservices.com
/Products/2011-10-01
AWSAccessKeyId=&Action=GetMyFeesEstimate&FeesEstimateRequestList.FeesEstimateRequest.1.IdType=ASIN&FeesEstimateRequestList.FeesEstimateRequest.1.IdValue=3828934897&FeesEstimateRequestList.FeesEstimateRequest.1.Identifier=request1&FeesEstimateRequestList.FeesEstimateRequest.1.IsAmazonFulfilled=true&FeesEstimateRequestList.FeesEstimateRequest.1.MarketplaceId=A1PA6795UKMFR9&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.Amount=30.00&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.ListingPrice.CurrencyCode=EUR&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Points.PointsNumber=0&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.Amount=3.99&FeesEstimateRequestList.FeesEstimateRequest.1.PriceToEstimateFees.Shipping.CurrencyCode=EUR&SellerId=XXXXXXXXXXXXXX&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2018-06-12T04%3A19%3A55Z&Version=2011-10-01

How to store payload and append it to another payload later?

I am using Spring Integration in my project. I have the following payload.
<?xml version="1.0" encoding="UTF-8"?>
<PQ>
<PQContact>
<hostAddress>10.193.244.136</hostAddress>
</PQContact>
<workflowStatusComment>
<comment>I am here</comment>
</workflowStatusComment>
</PQ>
I want to extract the tag <workflowStatusComment> i.e workflowStatusComment <comment>I am here</comment></workflowStatusComment> and save it for future purpose. I don't want to use any java code to use the saved tag info in the future. I want to add the saved info to another payload at the end of the execution.I know about header enrichers, but I don't know how to use the saved header enriched values without using java. I have to only use Spring Integration components to manipulate the payload.
The second payload to which I am going to append the saved tag info is here:
<?xml version="1.0" encoding="UTF-8"?>
<PQ>
<PQContact>
<hostAddress>10.193.244.136</hostAddress>
<name>Ashok</name>
<userId>007</userId>
</PQContact>
</PQ>
After appending the saved tag info to the above payload, my final payload should look like the initial payload with some extra information. Something like below:
<?xml version="1.0" encoding="UTF-8"?>
<PQ>
<PQContact>
<hostAddress>10.193.244.136</hostAddress>
<name>Ashok</name>
<userId>007</userId>
</PQContact>
<workflowStatusComment>
<comment>I am here</comment>
</workflowStatusComment>
</PQ>
is there any way?
You can extract that info from the XML using <int-xml:xpath-transformer> or #xpath() SpEL-function.
But you have to share with us what is your "another payload" and how you would like to add this extracted.
Maybe it even better to have some solution with Java and than we consider here how to convert it into Spring Integration XML DSL or similar.
Please, revise your question to make it more clearer.
UPDATE
To insert one XML into another you have to fight a bit javax.xml API.
The code might be something like this:
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document target = builder.parse(new StringBufferInputStream(targetXML));
Element source = builder.parse(new StringBufferInputStream(sourceXML)).getDocumentElement();
target.appendChild(source);
UPDATE 2
But I don't want to use any java code.
Well, if your target XML can represent as a template string you can use standard replaceFirst() in the <transformer> with expression:
String targetXml = "";
<transformer expression="'<?xml version="1.0" encoding="UTF-8"?>
<PQ>
<PQContact>
<hostAddress>10.193.244.136</hostAddress>
<name>Ashok</name>
<userId>007</userId>
</PQContact>
$workflowStatusCommentToken$
</PQ>'.replaceFirst('\\$workflowStatusCommentToken\\$', headers.originalXml)"/>

Resources