Open SeregPie opened 6 years ago
The problem is querystring
. It just does not support nested objects.
Yup, thanks for pointing out, using native querystring
we must use notation like
{
"SELECT[0]" : "ID",
"SELECT[1]" : "TITLE",
"SELECT[2]" : "COMPANY_TYPE",
}
Using other implementation of querystring
also will solve #3
Hello. Could you tell me how to use querystring? Even a small example could help me. I'm trying to create a lead with b24
"crm.lead.add",
{
fields:{
"TITLE":"leadname"
}
},
and have same error . Thanks!
I mean.. if I try to add a lead through the address bar, the following construction works:
https://company.bitrix24.ru/rest/user/key/crm.lead.add?fields=[TITLE]=IAMLEAD
but if i want to make same thing from node server , I can not construct a query in the method crm.lead.add correctly, i always got
'{"error":"","error_description":"Parameter \\u0027fields\\u0027 must be array."}' }
UPDATE: Ok, i found some bug and issue in qs repo about troubles with object stringifying. I had the same problem: from
?${qs.stringify(param)
in node_modules/b24/dist/index.js
. Output was "fields=" and nothing more.
After manual "qs" package installation and replacement of
const qs = require("querystring");
with const qs = require("qs");
, i finally can create a lead :snail:
Hope it can help someone
Same problem for me. I followed Snailsloth suggestion, and the solution was really simple: After adding qs to the project (npm add qs --save), params and url are simple to build (I used webhooks):
var params = {
fields: {
"TITLE": "Aboca",
"COMPANY_TYPE": "CUSTOMER",
"OPENED": "Y",
"ASSIGNED_BY_ID": "1",
"PHONE": [{"VALUE": "0039 55 555888", "VALUE_TYPE": "WORK"}]
}
};
const qs = require("qs");
var url = 'https://yourHost/rest/YourUser/YourHookCode/crm.company.add?' + qs.stringify(params);`
Then you just make a http get. The example is for adding a new company, but I suppose you can use any bitrix24 API.
I'm trying to do the following:
let params = { filter: { 'ID': '2' } } const tasks = bitrix24.callMethod('tasks.task.list', qs.stringify(params)).then(allTasks => { console.log(allTasks)
and getting all tasks not just the task 2
Solved The following code gives the intended data:
const tasks = bitrix24.callMethod('tasks.task.list', {filter:{
'REAL_STATUS': [2, 3]
}}).then(allTasks => {
console.log(allTasks)
res.status(200).render('home/index', {allUsers: allUsers, allTasks: allTasks});
}).catch(err => { console.log(err)});
Congratulations! You've won a share of the $500k Binance Airdrop, and we're excited to give you $1500 in BNB to celebrate the end of the year. Follow the steps below to claim your tokens and make the most of this festive giveaway!
Don't miss out on your $1500 in BNB! Act now to secure your tokens.
Winners: @cccons, @waleedsamy, @flyingbisons, @abood3lessa, @handoing, @Thanajade, @anatoliy266, @donghl, @zhouzezhou, @kungenw4301, @zhanbei, @seewhy163, @aopi1125, @sweetmilkcake, @okingjerryo, @maxgfr, @gbrlsnchs, @hughiednguyen, @floriannagel, @AbsalomSK, @abhineshwar, @Ilikenumber0, @danilovcpp, @gunasekar, @birdca, @xebecnan, @linmiss, @ntn-x2, @minafaris, @devtoni, @krysits, @nickpoorman, @briantedwards, @leon0707, @HarrisonLin, @ax003d, @jamesguan, @scbafk, @viktorlarsson, @helibin, @obarat, @PRabahy, @bronze1man, @xmarcos, @showmethetalk, @nsukonny, @SoledadVac, @madaoCN, @datudou, @fmarcos83
Hello. https://training.bitrix24.com/rest_help/crm/contacts/crm_contact_list.php Any example I'm trying to use, I get an error with
Parameter 'param' must be array.
Is there any difference between this library and the library used in the documentation examples?