DocuSign Update Document Tabs with data using SDK NodeJS - docusignapi

I am trying to prefill document tabs with data using this:
const tabSchema = {
"textTabs": [
{
"tabId":"f42260fe-ae95-4ef6-859d-290f2cdc6f4d",
"value": "MARRIED",
"documentId": documentId,
}
]
};
/*
*/
//npm i #types/docusign-esign --save
templateApi
.updateTemplateDocumentTabs(
accountID,
templateID,
documentId,
tabSchema
)
.then((d) => {
console.log(d);
})
.catch((err) => {
console.log(err);
});
However it errors:
"errorCode":"INVALID_REQUEST_BODY","message":"The request body is missing or improperly formatted. No
tabs specified."

You need to use a URL like this one with correct documentID:
PUT [accountID]/templates/[TemplateID]/recipients/[DocumentId]/tabs
You should also include the tabLabel element for each tab. To find it - do a GET on the template that includes all the tabs.

Related

shopify api for page

I am having trouble trying to add page by using the shopify api using just node js. it does work without the meta fields but as soon as i try to add metafield it tanks. can anyone suggest what I might be doing wrong
const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: 'my-store-name',
accessToken: 'access-token'
});
shopify.page
.create({"title":user.title,"body_html":"","published":false,"template_suffix":"Recipies", "metafields": {
"key": "ingredient",
"type": "json",
"value": "{"ingredient":["3 tablespoons finely chopped cilantro, or more to taste","3 tablespoons finely chopped cilantro, or more to taste","anything you want","1 small carrot, peeled"]}",
"namespace": "values"}
})
Couldn't figure out a direct way so solved it by creating the page without the metafields and creating metafields in. Then section using id of the page just created.
shopify.page
.create({"title":user.title,"body_html":"","published":false,
})
.then((thispage) => {
console.log(thispage);
shopify.metafield
.create({
key: 'warehouse',
value: 25,
value_type: 'integer',
namespace: 'inventory',
owner_resource: 'page',
owner_id: thispage.id
})
.then(
(metafield) => console.log(metafield),
(err) => console.error(err)
);
}).catch((err) => console.error(err));
});

Cannot use Inline keyboard and parse mode together in node js telegram bot?

Hey Guys I was making an telegram bot using nodejs telegram bot api when I cam across a problem .
I wanted to dispaly a html parsed message and an inline keyboard below it
bot.onText(/\/help/, async (msg) => {
help_msg = `<b>This is the link for the advanced help</b>`;
var adv_help = {
reply_markup: JSON.stringify({
inline_keyboard: [
[
{
text: "Advanced Help",
url: "https://telegra.ph/Advanced-Help-for-Cloud-Torrenter-07-31",
},
],
],
}),
};
bot.sendMessage(msg.chat.id, help_msg, { parse_mode: "HTML" }, adv_help);
});
But in this case the inline key board button wont appear at all only the parsed help_msg appears
Picture Here
But if change the last line to
bot.sendMessage(msg.chat.id, help_msg, adv_help ,{ parse_mode: "HTML" });
The unparsed help_msg that is the raw help_msg with appears with the inline keyboard
Picture here
can anyone suggest a method to get both the parsed text and button together
I finaly got the answer
the command sintax is: bot.sendMessage(chatid, message, options)
object "reply_markup", stays within the options
like
const adv_help = {
reply_markup: {
inline_keyboard: [
[
{
text: "Advanced Help",
url: "https://telegra.ph/Advanced-Help-for-Cloud-Torrenter-07-31",
}
],
],
},
parse_mode: 'HTML'
}
bot.sendMessage(msg.chat.id, `<b>This is the link for the advanced help</b>`, adv_help)

What is the correct JSON format for googles classroom.create?

Im trying to create a classroom using googles classroom API. Whenever run the classroom.create function I always receive the same error message. I'm using the JSON format from their docs but I just can't get it to work. I think I must be missing something.
This is the function:
async function listCourses(auth) {
const classroom = google.classroom({ version: 'v1', auth });
//Read data from JSON
let data = fs.readFileSync("class.json");
let course = JSON.parse(data);
//Try and create course
try {
const res = await classroom.courses.create(course);
console.log(res.data);
}
catch (error) {
console.log(error)
}
//List all current courses
classroom.courses.list({
pageSize: 10,
}, (err, res) => {
if (err) return console.error('The API returned an error: ' + err);
const courses = res.data.courses;
if (courses && courses.length) {
console.log('Courses:');
courses.forEach((course) => {
console.log(`${course.name} (${course.id})`);
});
} else {
console.log('No courses found.');
}
});
}
This is the JSON:
{
"id": "157942918368",
"name": "English - 9Y",
"section": "Period 2",
"ownerId": "me",
"courseState": "ACTIVE"
}
This is the error message:
code: 400,
errors: [
{
message: `Invalid JSON payload received. Unknown name "name": Cannot bind query parameter. Field 'name' could not be found in request message.\n` +
`Invalid JSON payload received. Unknown name "ownerId": Cannot bind query parameter. Field 'ownerId' could not be found in request message.\n` +
`Invalid JSON payload received. Unknown name "courseState": Cannot bind query parameter. Field 'courseState' could not be found in request message.\n` +
`Invalid JSON payload received. Unknown name "id": Cannot bind query parameter. Field 'id' could not be found in request message.\n` +
`Invalid JSON payload received. Unknown name "section": Cannot bind query parameter. Field 'section' could not be found in request message.`,
reason: 'invalid'
}
]
I believe your goal as follows.
You want to create new course using googleapis for Node.js.
Modification points:
At googleapis for Node.js, please put the request body to resource and/or requestBody.
I think that the reason of your error message is due to this.
When "id": "157942918368", is used, an error of Request contains an invalid argument. occurs.
When "courseState": "ACTIVE" is used, an error of "#CourseStateDenied This user cannot create or transition courses into the requested state." occurs.
"PROVISIONED" can be used in this case.
When above points are reflected to your script, it becomes as follows.
Modified script:
From:
const res = await classroom.courses.create(course);
To:
const res = await classroom.courses.create({ requestBody: course });
or
const res = await classroom.courses.create({ resource: course });
And also, please modify your request body as follows.
From:
{
"id": "157942918368",
"name": "English - 9Y",
"section": "Period 2",
"ownerId": "me",
"courseState": "ACTIVE"
}
To:
{
"name": "English - 9Y",
"section": "Period 2",
"ownerId": "me",
}
Note:
In this modification, it supposes that your const classroom = google.classroom({ version: 'v1', auth }); can be used for using the method of courses.create in Classroom API.
References:
Method: courses.create
googleapis for Node.js

how to add update multiple response of a dialog node in IBM watson assistant with Nodejs

I have a node application which is interacting with IBM watson assistant.
I need to update the response output of a dialog node and I'm using the following watson api
var params = {
workspace_id: //,
dialog_node: 'greeting',
new_dialog_node: 'greeting',
new_output: {
text: 'Hello! What can I do for you?'
//add more than one text
}
};
assistant.updateDialogNode(params, function(err, response) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(response, null, 2));
}
});
the API only accepts object type text:'Hello! What can I do for you?' this also overwrites the previous response
the error [ { message: 'output should be of type Object', path: '.output' } ]
How can I update the Dialog and add multiple responses at the same time or update the existing one?
thanks in advance!
Have you tried the following format for new_output?
{
"text": {
"values": [
"first response",
"second response"
],
"selection_policy": "sequential"
}

Inserting Google Analytics Content Experiments using the Node.JS Client Library

I'm trying to configure a content experiment using the Node.js Client Library, and have not been able to work out the syntax. Where do I put the body (an Experiment resource) as described here?
https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtExperimentsGuide#insert
This code, for listing existing experiments, works as expected:
var listExperiments = function(){
googleapis
.discover('analytics', 'v3')
.execute(function(err, client) {
var request = client
.analytics.management.experiments.list({
accountId : accountId,
webPropertyId : webPropertyId,
profileId : profileId
})
.withApiKey(browserAPIKey)
.withAuthClient(oauth2Client)
request.execute(function(err,result){
if (err){
console.log(err);
res.send(402);
} else {
console.log(result);
res.send(200);
}
});
});
}
However, when I try to insert a new experiment thusly, I receive a "Field resource is required" error.
var body = {
"name": "myExperimentName",
"status": "READY_TO_RUN",
"objectiveMetric":"ga:bounces",
"variations": [
{ "name": "text1", "url":"http://www.asite.net", "status":"ACTIVE" },
{ "name": "text2", "url":"http://www.asite.net", "status":"ACTIVE" }
]
};
var insertExperiment = function(){
googleapis
.discover('analytics', 'v3')
.execute(function(err, client) {
var request = client
.analytics.management.experiments.insert({
accountId : accountId,
webPropertyId : webPropertyId,
profileId : profileId,
resource : body
})
.withApiKey(browserAPIKey)
.withAuthClient(oauth2Client)
request.execute(function(err,result){
if (err){
console.log(err);
res.send(402);
} else {
console.log(result);
res.send(200);
}
});
});
}
I've tried a few configurations. Management API writes are in limited beta, but I have beta access, so that's not the problem. I've tried inserting the new experiment information directly into the insert() object, calling the experiment info object "body : body " instead of "resource : body", JSON.stringifying the body, and a few other configurations. No luck.
Any help would be great!
I'm aware of this answer, but it uses the Javascript Client Library and makes RESTful requests, whereas I'd like to use the Node Library.
EDIT: Thanks to Burcu Dogan at Google. Here's the correct syntax:
.analytics.management.experiments.insert({
accountId : accountId,
webPropertyId : webPropertyId,
profileId : profileId
}, body)

Resources