I want to add custom tag defined in docisign on my document through REST API call in Apex - rest

I want to add AccountName custom tag defined in docusign on my document through REST API call in Apex. Here is my REST API request body
{
"status" : "sent",
"customFields" : {
"textCustomFields" : [ {
"name" : "AccountName",
"show" : "true",
"required" : "False",
"value" : "Test Account",
"customFieldType" : "text"
} ]
}
}
The URL is https://demo.docusign.net/restapi/v2/accounts/'accountId'/envelopes
I use anchor string /txtAccountName1/ which I have added on my document but it does not map to any value of the custom field AccountName related to salesforce object. For the tabs it works fine it successfully maps the signer tag to s1 and date to the d1 but for this custom field it does not map the AccountName custom tag to the anchor string /txtAccountName1/. I have created the custom tag AccountName related to salesforce object and used anchor string as /txtAccountName{r}/. I am writing the code in sandbox and using Docusign Demo Account for the integration.I am not sure about the name used in textCustomField and value I used is the reason for not getting the required result. Though the Rest API request is returning the sucess.
How can I map the AccountName value to the anchorString defined in my document?

You are mixing two things customtab and customfields. CustomFields is the metadata on an envelope, there is no tab for this and you can send text type of list type custom fields, these type of fields are not visible to a signer/recipient and is sent as metadata in an envelope, For details related to CustomFields are available at https://docs.docusign.com/esign/restapi/Envelopes/EnvelopeCustomFields/create/
Now customTab, if you have already defined an account level customTab as "AccountName" then you can add them using REST API using below call like:
{
"textTabs": [{
"tabLabel": "AccountName",
"documentId": "83644555",
"recipientId": "84066562",
"pageNumber": 1,
"value": "AccountName",
"anchorString": "/txtAccountName1/"
}]
}
So before using the Accountlevel custom tab, you need to create it in your DocuSign account from webapp or using API - https://docs.docusign.com/esign/restapi/CustomTabs/CustomTabs/create/, Once it is created then only you can use it in an envelope.

As far as I can tell, you can't pull in the custom tag definition. You need to define the entire tag every time you use it, which means you'll need to use something like this:
"textCustomFields" : [ {
"name" : "AccountName",
"show" : "true",
"required" : "False",
"value" : "Test Account",
"anchorString": "/txtAccountName1/"
"customFieldType" : "text"
} ]

Related

Magento 2.4 API, POST product custom_attributes

I need to add/update products using the REST API. I cannot figure how to add a custom_attributes, knowing only the value/label of the attribute and not the ID (attribute of type 'dropdown' or 'selectable')
POST /rest/all/V1/products
{
"product": {
"sku": "D119",
"custom_attributes": [{
"attribute_code": "year",
"value": "2015"
}]
}
}
Upper code works fine if I just put in the ID in the value field. But a sourcing system wouldnt know the id's....
Side note: The M2 backend import function is capable of importing value/label of the attribute? How come?

How to pass owner attribute when creating user story using Rally API?

I am trying to pass the owner attribute to create a user story in rally using rally API But I am encountering below error.
{
"CreateResult": {
"_rallyAPIMajor": "2",
"_rallyAPIMinor": "0",
"Errors": [
"Cannot parse object reference from \"{\"Owner\": {\"_refObjectName\": \"Ron\"}}\""
],
"Warnings": [
"Ignored JSON element HierarchicalRequirement.PortfolioItem during the processing of this request."
]
}
}
My request payload
{
"HierarchicalRequirement":{
"Name": "hello Wrold",
"Description":" 123 test description",
"Workspace": "/workspace/18686460234",
"Project":"/project/1025697468602323",
"PortfolioItem":"",
"Owner":{"_refObjectName":"Ron"},
"ScheduleState":"Defined"
}
}
Any thoughts?
In general, when referring to an object property that itself is an object (as in this case with the User object), you pass in the actual value of _ref, not another object. If you have previously been passed the reference to the user as a full blown URI, then you can still pass that in and the SDK will convert it to a _ref.
If you go to the webservice docs (https://rally1.rallydev.com/slm/doc/webservice/) for your subscription and go down to the User section, you can get the docs to fetch you some examples of users. The _ref will come back something like:
https://rally1.rallydev.com/slm/webservice/v2.0/user/39776836851
I believe that you can either use that, or just truncate it to the number at the end. So the code will need to be changed so that the Owner line reads:
"Owner" : "https://rally1.rallydev.com/slm/webservice/v2.0/user/39776836851"

Magento 2 REST API Customer Custom Attribute

The Magento 2 REST API Documentation explains a way to set custom_attributes on a customer when updating or creating it. http://devdocs.magento.com/swagger/index_20.html#/
Unfortunately I couldn't get this to work...
My POST and PUT JSON request data is :
{
"customer": {
"custom_attributes": [
{
"attribute_code": "firstname",
"value": "TEST"
}
],
"email": "someone#exaxmple.com",
"extension_attributes": [],
"firstname": "Someone",
"gender": null,
"lastname": "Else",
"middlename": null,
"taxvat": null,
"website_id": "1"
}
}
The Customer is created but the Firstname is not "TEST".
Is there anyone who had the same problem and fixed it? Please let me know how.
My best guess is that, since Firstname is an existing Out-Of-The-Box attribute - the OOTB attribute name-value mapping assignment will take precedence.
Could you try again, with a unique custom attribute name (i.e. something that doesn't clash with OOTB attribute names)
You will need to DEFINE a custom-customer-attribute before you can use the M2 API to perform operations on that custom-customer-attribute.
This StackExchange thread - https://magento.stackexchange.com/questions/88245/magento2-create-a-customer-custom-attribute - has additional information on how to go about setting up a custom-customer-attribute.

Creating JWT custom claims in DataPower

Running on DataPower 7.5.2.0
I created a JWT Generator as part of a AAA Policy and it is working fine, I am able to generate, sign and then externally verify the JWT with no issues.
Now I want to add a custom claim to the JWT, so I ticked the box for Custom and then uploaded this Gateway script file:
var claim = {
"result" : {
"user" : "hardcode"
}
};
session.output.write(claim);
and it generates the correct JWT with the user attribute. However when I try to add a second value to it like so:
var claim = {
"result" : {
"user" : "hardcode",
"name" : "myname"
}
};
session.output.write(claim);
I now get this error:
[Error: Required CustomClaim Name or Value field missing] errorMessage: 'Required CustomClaim Name or Value field missing', errorCode: '0x8580005c', errorDescription: 'GatewayScript console log message.', errorSuggestion: 'GatewayScript console log message. Refer to the message for more information.'
Which is the same message I got before I realized I had to set the output to result from the InfoCenter's vague documentation.
How do I add multiple custom claims in the JWT Generator Gateway script??
It would appear that DataPower only allows you to add a single custom claim, so you just need to make that a complex object like so:
var claim = {
"result" : {
"claim" : {
"user" : "hardcode",
"one" : true,
"clientId" : "asdf-asdf-asdf",
"endpoint" : "http://192.168.142:8080/member/ws"
}
}
};
session.output.write(claim);
This then generates the correct JWT with a nest claim.
eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhcGljIiwic3ViIjoiYWRtaW4iLCJleHAiOjE0ODIyNjU5ODQsImlhdCI6MTQ4MjI2MjM4NCwianRpIjoiZDhjNTE1ZDEtZmVjMS00ZGVmLThiNDctZmYzY2E2OWVjOWRiIiwibm9uY2UiOiJtN2lVZlBqTCIsImF1ZCI6ImlkMSIsImNsYWltIjp7InVzZXIiOiJmcmVkIiwib25lIjp0cnVlLCJjbGllbnRJZCI6ImFzZGYtYXNkZi1hc2RmIiwiZW5kcG9pbnQiOiJodHRwOi8vMTkyLjE2OC4xNDI6ODA4MC9tZW1iZXIvd3MifX0.viakwnM5bhhmGIn0QmDJTmsWCuIciO2BOdUVyxYpsFA

Passing discount code in Orders API on Shopify

I have been trying to develop an app that takes an order on Shopify on a different channel. I successfully placed an order through the API but I am not able to include the discount code along with the order. The JSON object for the POST data is as below:
{
order: {
email : request.params.order.email, // string
financial_status : 'pending', // string
send_receipt : true, // boolean
send_fulfillment_receipt : false, // boolean
note : request.params.order.note, // string
discount_codes : [], // supposed to be an array of Object| Problem here,
line_items : request.params.order.line_items, // array
customer : request.params.customer, // JSON object
billing_address : request.params.order.billing_address, // JSON object
shipping_address : request.params.order.shipping_address // JSON object
}
}
According to the documentation, the discount_codes is like this -
Applicable discount codes that can be applied to the order. If no codes exist the value will default to blank. A Discount code will include the following fields:
amount: The amount of the discount.
code: The discount code.
type: The type of discount. Can be one of : "percentage", "shipping", "fixed_amount" (default).
What am I doing wrong? My discount_codes is this
[{amount: 100,code:'WELCOME10',type:'percentage'}]
Has anyone done this before?
According to this response from Shopify what you are trying to do is only possible if you pass the total_discounts field along as well with the total amount of the discount you want to apply.
As you will see in this other answer, any codes you have created through Shopify are not available to use with the API and their usage will not be recorded.
I was trying to use this API in order to test the application of different coupon codes that I was generating, but this does not seem to be possible. Apparently, the API was intended for applying discounts that are custom, not ones that already exist in Shopify. This is a frustrating limitation to me.
I successfully create orders with discounts all the time, without ShopifyPlus as that is irrelevant. The data structure that works for me looks like this:
[ { "code": "Shop By PizzleFuzzle 10%", amount: "10", "type": "percentage" } ]
The discount object is available only for Shopify Plus merchants.
Once you are a Shopify Plus merchant, you will be able to create discount codes like that:
POST /admin/discounts.json
{
"discount": {
"discount_type": "percentage",
"value": "15.0",
"code": "balderdash"
}
}
Please see more detailed documentation in the discount object at Shopify API: https://help.shopify.com/api/reference/discount
You should use the value property name instead of amount property name.
e.g.
{value: 100,code:'WELCOME10',type:'percentage'}
and not
{amount: 100,code:'WELCOME10',type:'percentage'}