Missing required field: member - node.js

{ errors:
[ { domain: 'global',
reason: 'required',
message: 'Missing required field: member' } ],
code: 400,
message: 'Missing required field: member' }
I get this error when I run the following request:
var request = client.admin.members.insert({
groupKey: "some_group#example.com"
, email: "me#example.com"
});
I was authenticated successfully (I received the access token and so on) but when I execute the request above it callbacks that error.
What member field am I supposed to add?
It works fine in API Explorer using groupKey and email fields.

The documentation at https://developers.google.com/admin-sdk/directory/v1/reference/members/insert for admin.members.insert indicates that it requires a groupKey parameter, but that the body (which the node.js library handles as a separate object) should contain a members object containing the role property. See the API Explorer a the bottom of that page as well.

email is part of the form data. The form data must be passed as object in the second argument:
// create the group insert request
var request = client.admin.members.insert({
groupKey: "some_group#example.com"
}, {
email: "me#example.com"
});

Related

Discord.js creating channel error - Invalid Form Body

I've been trying to create a ticket bot and create channels that have tickets within them. However, when I try and create them it returns an error
Code:
const channel = await interaction.guild.channels.create(`ticket-${interaction.user.username}`, {
parent: '929135588949512232',
topic: interaction.user.id,
type: 'GUILD_TEXT',
})
Error:
DiscordAPIError[50035]: Invalid Form Body
name[BASE_TYPE_REQUIRED]: This field is required
Any help would be appreaciated
If you look at the documentation, only one parameter is required for the channel create method, therefore the code should look like this:
const channel = await interaction.guild.channels.create({
name: `ticket-${message.interaction.username}`,
parent: "929135588949512232",
topic: interaction.user.id,
type: Discord.ChannelType.GuildText,
});
Refer to the docs here
https://discord.js.org/#/docs/discord.js/main/class/GuildChannelManager?scrollTo=create
The error is caused, because you passed in information, such as the type, in the second parameter, not the first.

Is there a way to fix this Mailchimp API error in node?

Is there a way to fix this MailChimp API error in Node.js?
{
type: 'http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/',
title: 'Invalid Resource',
status: 400,
detail: "The resource submitted could not be validated. For field-specific details, see the 'errors' array.",
instance: '95a2824e-4f30-4ce4-8c5e-322859d933e4',
errors: [
{
field: 'members.item:0.status',
message: 'Data presented is not one of the accepted values: subscribed, unsubscribed, cleaned, pending.'
}
]
}
What is the API call the Node app is trying to do? Looks like its trying to add a member to a list, so assuming you are making this request POST /lists/{list_id}/members
The required fields in the body needs to be:
{
"email_address": "",
"status": ""
}
Based on the error message, you are not passing in a status in the POST request. Possible values are the following: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional".

Stripe warning - Unrecognized token creation parameter

I'm just starting with stripe, and I noticed I get a warning in chrome saying:
Unrecognized token creation parameter parameter: company is not a
recognized parameter. This may cause issues with your integration in
the future.
This is the code.
stripe.createToken("account", {
company: {
name: "bbb",
address: {
line1: "77",
city: "abc",
state: "aa",
postal_code: "e2e"
}
},
tos_shown_and_accepted: true
}).then(function(result) {
debugger;
console.log(result);
});
I'm pretty much following the docs here (step 2)
https://stripe.com/docs/connect/account-tokens
It creates a token OK though.
The docs in the API reference suggest company is an object it should know:
https://stripe.com/docs/api/tokens/create_account
It basically tells you what is wrong.
It says that company is not a parameter that is recognized by that stripe endpoint. It creates the token, but ignores your passed parameter

JHipster - JhiAlertService - How to decide how long alerts are displayed?

I have generated a JHipster project with version 4.9.0.
I am using the JhiAlertService to display various messages to users.
I would like to know how to send in parameters to indicate how long the messages are displayed.
JhiAlertService comes from the ng-jhipster library.
You can view the code of alert.service.ts to see the available parameters.
For customizing the timeout, use the addAlert method and pass it a JhiAlert object containing a timeout parameter:
this.alertService.addAlert({type: 'success', msg: 'A short message', timeout: 1000}, []);
Note that if you are using the i18n option, the msg field is the name of the i18n JSON key, and the params field should contain any information that is interpolated into the message. So for displaying an alert when the "Admin" user is saved successfully, you would use:
this.alertService.addAlert({type: 'success', msg: 'userManagement.updated', params: { param: 'admin' }, timeout: 1000}, []);

I'm trying to make sense of session, but cannot get any data out of it

Currently using LUIS in a bot that connects to Slack. Right now I'm using interactive messages and trying to respond to user input correctly. When I click an item from the drop down LUIS receives it as a message. I can get the text with session.message.text, however I need to get the callback_id of the attachment as well as the channel it was sent from.
I've used console.log(session) to get an idea of what session looks like. From there I've seen that session.message.sourceEvent contains the data I need, however I can't use indexOf() or contains() to actual extrapolate the data. I've also tried session.message.sourceEvent.Payload but end up getting "[object [Object]]". I've tried searching for documentation on session formatting but to no avail.
Below is a snippet of what is returned when I run console.log(session.message.sourceEvent).
{ Payload:
action_ts: '1513199773.200354',
is_app_unfurl: false,
subtype: 'bot_message',
team: { id: 'T03QR2PHH', domain: 'americanairlines' },
user: { id: 'U6DT58F2T', name: 'john.cerreta' },
message_ts: '1513199760.000073',
attachment_id: '1',
ts: '1513199760.000073' },
actions: [ [Object] ],
callback_id: 'map_selection1',
original_message:
username: 'Rallybot',
response_url: 'https://hooks.slack.com/actions/T03QR2PHH/287444348935/Y6Yye3ijlC6xfmn8qjMK4ttB',
type: 'message',
{ type: 'interactive_message',
channel: { id: 'G6NN0DT88', name: 'privategroup' },
token: 'removed for security',
{ text: 'Please choose the Rally and Slack team you would like to map below.',
bot_id: 'B7WDX03UM',
attachments: [Array],
trigger_id: '285857445393.3841091595.085028141d2b8190b38f1bf0ca47dd88' },
ApiToken: 'removed for security' }
session.message.sourceEvent is a javascript Object, however indexOf or contains are functions of String or Array types.
Any info you required in the object, you should direct use the code <object>.<key> to invoke that value. You can try session.message.sourceEvent.Payload.action_ts for example.
Also, you can use Object.keys(session.message.sourceEvent) to get all the keys in this object.

Resources