Asana API POST to Tasks leads to Server Error - node.js

I'm using node.js and the api key for auth. All my get actions work, and I've been able to post a new project, but new tasks always return 'server error'. Here's the object I'm sending to the /tasks endpoint:
data: {
name: 'Figure this out',
notes: '',
assignee: null,
completed: false,
assignee_status: 'later',
completed_at: null,
due_on: null,
tags: [],
parent: null,
followers: [ { id: 5622986387066 }, { id: 5622895459066 } ],
projects: [ 6156399090409 ],
workspace: 1707039411020
}
Any ideas? I've tried passing those ID values a variety of ways, and I've tried creating a more simple task, always fails with a 'server error' response.

Seems like it's the "parent": null that's causing the unhelpful Server Error, which definitely seems like a bug on our side - I've filed it and will hopefully get time to look into it soon. Trim that out, and it gives you actual error messages.
Just to save you some time: you can't set completed_at or tags, and followers should be just an array of integers ("followers": [ 5622986387066, 5622895459066 ]).
You can set completed: [true/false], and the completed_at will be set to the time at which it was marked complete. Not being able to attach tags to a task is a known issue, and one we're hoping to rectify.
Additionally, it's just a little annoying that the format of a response doesn't map 1-1 to the format for posting/updating. We're hoping to do a pass on the overall design of the API to unify those parts a bit more.

Related

Meilisearch index not being created

I have been using Meilisearch for a couple of months and have recently upgraded to 0.26.0. For some reason, when I am today trying to create an index using the node package, nothing seems to happen.
I can successfully use the createIndex method like below:
client.createIndex("movies")
and the return value for the method shows the task:
{
uid: 26858,
indexUid: 'movies',
status: 'enqueued',
type: 'indexCreation',
enqueuedAt: '2022-04-08T15:15:06.325108519Z'
}
However, when I look up this task it seems that it has not been started:
{
uid: 26858,
indexUid: 'movies',
status: 'enqueued',
type: 'indexCreation',
details: { primaryKey: null },
duration: null,
enqueuedAt: '2022-04-08T15:15:06.325108519Z',
startedAt: null,
finishedAt: null
}
And indeed I can't find the index using the getIndexes method.
Strangely I created an index without issue just a few days ago.
Any idea what the issue might be or how I could debug this?
Most of Meilisearch's asynchronous operations belong to a category called "tasks". Create an index is one of them.
Depending on the queue size and server processing power it may take a while to process recently created tasks.
You can find more information on section asynchronous operation of documentation.

mapper parsing exception in elastic search nodejs

i am a newbie to elasticsearch and was trying to index some json objects. My json object looks like this:
{
"name": "ABC",
"age":22,
"education": "XYZ",
"metadata": {
asset1:{
fingerprintID: "dnadklwdkl",
image: "URL"
}
}
}
Here, the metadata is given by the user and can be anything, null, an array, object of different things. other field like name, age, education are consistent but not metadata.so, i am having trouble indexing it. i was following this link: https://www.compose.com/articles/getting-started-with-elasticsearch-and-node/ and creating index for the data and pushing to the elastic server running locally. I have around 1 million json data like above fetched from a database and have no idea how the metadata will be. On creating the index and running the service, i get this error:
{ error:
{ root_cause: [ [Object] ],
type: 'mapper_parsing_exception',
reason: 'failed to parse',
caused_by:
{ type: 'illegal_argument_exception',
reason:
'Limit of total fields [1000] has been exceeded while adding new fields [2]' } },
some of received json data from database have been pushed to the server successfully, but most of them are not. How do i handle this issue? Can someone help?
According to the error message, it seems like some of your JSON objects have a lot of fields. By default, Elasticsearch allows only 1000 total fields within an object to prevent mapping explosion. If you know what you are doing, you can simply increase this limitation by doing:
PUT your_index/_settings
{
"index.mapping.total_fields.limit": 9999
}

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

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.

Mongodb: updating multiple docs in a loop?

I did a great effort to find a solution to this common situation, without success. Hoping somebody can help please.
Background:
A board of messages.
Each message has its msg_id.
Each user has an id
I need to track which user watched which message.
For this I have a collection called viewedMessages like this:
{
{ _id: <message_id_X>,
viewedBy: [<user_id_?>,<user_id_?>,...]
},
{ _id: <message_id_Y>,
viewedBy: [<user_id_?>,<user_id_?>,user_id_?>,...]
},
...
}
The user is calling my node.js server once in a while, reporting which messages were viewed, like this:
{ user_id: <user_id_?>, viewed: [<message_id_?>,...] }
An entry for a message is only created when some user is reporting it as viewed. This is done using this command:
db.viewedMessages.update({"_id":<msg_id>},{$addToSet:{viewedBy:<user_id>}},{ upsert : true });
Now for the question.
The above update command is asynchronous. How do I run over an array of [msg_id,msg_id,msg_id,...], issuing the above update command for each msg_id, and finally get a callback telling me that everything was done ok OR failed for some reason?
Would highly appreciate any help here!

Resources