open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.1k stars 590 forks source link

Error Create Product #2622

Closed trcalgaro closed 2 years ago

trcalgaro commented 2 years ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Multi-device and I have set multiDevice to true in my config OR am using the --multi-device flag

What type of host account are you experiencing this issue on?

Business account

Mode

EASY API/CLI

Current Behavior

Trying to create a product via API

Expected Behavior

create a product

Steps To Reproduce

  1. Easy API
  2. Config Request: curl -X 'POST' \ 'https://xxxxxxxxxxxxxxxx/createNewProduct' \ -H 'accept: */*' \ -H 'api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \ -H 'Content-Type: application/json' \ -d '{ "args": { "name": "Produto From API", "price": "50", "currency": "BRL", "images": ["https://a-static.mlcdn.com.br/1500x1500/robo-com-movimento-tectoys-agil-emite-som-luz-polibrinq/magazineluiza/226997000/6d199b47751be62af805477eb39bda3a.jpg", "https://files.tecnoblog.net/wp-content/uploads/2022/03/mini-cheetah-mit-edited.jpg"], "description": "Isso é uma descrição", "url": "https://www.google.com.br", "internalId": "1234556", "isHidden": "false" } }'
  3. Run request
  4. Error: { "success": false, "error": { "name": "Error", "message": "Evaluation failed: TypeError: Cannot read properties of undefined (reading '_serialized')\n at Object.window.WAPI.<computed> [as createNewProduct] (eval at <anonymous> (:1:10), <anonymous>:1:79054)\n at __puppeteer_evaluation_script__:1:86" } }

Error from terminal middleware -> error Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading '_serialized') at Object.window.WAPI.<computed> [as createNewProduct] (eval at <anonymous> (:1:10), <anonymous>:1:54186) at __puppeteer_evaluation_script__:1:86 at ExecutionContext._evaluateInternal (C:\Users\xxxx\AppData\Local\npm-cache\_npx\21fe510f43113ad2\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ExecutionContext.evaluate (C:\Users\xxxx\AppData\Local\npm-cache\_npx\21fe510f43113ad2\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)

create() code

No response

DEBUG INFO

{
  "WA_VERSION": "2.2210.9",
  "WA_AUTOMATE_VERSION": "4.33.2",
  "BROWSER_VERSION": "HeadlessChrome/100.0.4889.0",
  "START_TS": 1649125328152,
  "LATEST_VERSION": true,
  "CLI": true,
  "LAUNCH_TIME_MS": 26288,
  "ACC_TYPE": "BUSINESS",
  "chats": 1,
  "messages": 14,
  "contacts": 362,
  "isBiz": true,
  "isMd": true,
  "INSTANCE_ID": "ef5ad273-81de-40f8-aba0-5cb2f47ce92f"
}

Environment

- OS: Windows Server 2019
- Node: 17.8.0
- npm: 8.6.0

Screenshots/Logs

No response

Anything else?

No response

smashah commented 2 years ago

this should be fixed now. Please try again

trcalgaro commented 2 years ago

@smashah The error still persists Request: curl -X 'POST' \ 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/createNewProduct' \ -H 'accept: */*' \ -H 'api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \ -H 'Content-Type: application/json' \ -d '{ "args": { "name": "Teste From API", "price": "12", "currency": "BRL", "images": ["https://agropos.com.br/wp-content/uploads/2021/03/Estacao-meteorologica-automatica-na-fazenda.jpg"], "description": "A estação meteorológica é uma ferramenta fundamental.", "url": "https://www.google.com.br", "internalId": "000001", "isHidden": "false" } }'

Error { "success": false, "error": { "name": "Error", "message": "Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')\n at Object.window.WAPI.<computed> [as createNewProduct] (eval at <anonymous> (:1:10), <anonymous>:1:58957)\n at __puppeteer_evaluation_script__:1:86" } }

smashah commented 2 years ago

hi, i dont have a business MD acc so you will need to bear with me to resolve this. Please try again in a few minutes. thanks

trcalgaro commented 2 years ago

Request curl -X 'POST' \ 'https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/createNewProduct' \ -H 'accept: */*' \ -H 'api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \ -H 'Content-Type: application/json' \ -d '{ "args": { "name": "Teste API", "price": "17", "currency": "BRL", "images": ["https://agropos.com.br/wp-content/uploads/2021/03/Estacao-meteorologica-automatica-na-fazenda.jpg"], "description": "essa é uma descrição do produto", "url": "https://www.google.com.br", "internalId": "000001", "isHidden": "false" } }'

Return { "success": false, "error": { "name": "Error", "message": "Evaluation failed: TypeError: Cannot destructure property 'chatParticipantCount' of 'e' as it is undefined.\n at new A (https://web.whatsapp.com/bootstrap_qr.8c19f3b9920c01c16ec8.js:69:332276)\n at Object.window.<computed>.<computed> [as procFiles] (__puppeteer_evaluation_script__:1:393775)\n at eval (eval at <anonymous> (:1:10), <anonymous>:1:85656)\n at Array.map (<anonymous>)\n at Object.window.<computed>.<computed> [as createNewProduct] (eval at <anonymous> (:1:10), <anonymous>:1:84758)" } }

Terminal middleware -> error Error: Evaluation failed: TypeError: Cannot destructure property 'chatParticipantCount' of 'e' as it is undefined. at new A (https://web.whatsapp.com/bootstrap_qr.8c19f3b9920c01c16ec8.js:69:332276) at Object.window.<computed>.<computed> [as procFiles] (__puppeteer_evaluation_script__:1:393775) at eval (eval at <anonymous> (:1:10), <anonymous>:1:85656) at Array.map (<anonymous>) at Object.window.<computed>.<computed> [as createNewProduct] (eval at <anonymous> (:1:10), <anonymous>:1:84758) at ExecutionContext._evaluateInternal (C:\Users\xxxxxx\AppData\Local\npm-cache\_npx\21fe510f43113ad2\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ExecutionContext.evaluate (C:\Users\x\xxxxxAppData\Local\npm-cache\_npx\21fe510f43113ad2\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)

trcalgaro commented 2 years ago

@smashah If you want I can provide access to my api, this number I use for testing. Call me by email if you want me to send you the API KEY

smashah commented 2 years ago

@trcalgaro i think the resolution to this issue is to make a chat with your own host account.

Do this via the mobile app then try again.

smashah commented 2 years ago

actually I think you can try again without making a chat with yourself

trcalgaro commented 2 years ago

Runing on Linux Machine return this error:

middleware -> error Error: Evaluation failed: TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'. at https://web.whatsapp.com/bootstrap_qr.8e365468263647825bd5.js:51:405672 at Y (https://web.whatsapp.com/bootstrap_qr.8e365468263647825bd5.js:5:273292) at new y (https://web.whatsapp.com/bootstrap_qr.8e365468263647825bd5.js:5:265859) at c (https://web.whatsapp.com/bootstrap_qr.8e365468263647825bd5.js:51:405336) at Object.<anonymous> (https://web.whatsapp.com/bootstrap_qr.8e365468263647825bd5.js:51:32595) at Generator.next (<anonymous>) at t (https://web.whatsapp.com/vendor1~bootstrap_qr.d16f7b9f073b657b8f2a.js:2:62943) at s (https://web.whatsapp.com/vendor1~bootstrap_qr.d16f7b9f073b657b8f2a.js:2:63154) at https://web.whatsapp.com/vendor1~bootstrap_qr.d16f7b9f073b657b8f2a.js:2:63213 at Y (https://web.whatsapp.com/bootstrap_qr.8e365468263647825bd5.js:5:273292) at ExecutionContext._evaluateInternal (/home/xxxxxx/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ExecutionContext.evaluate (/home/xxxxxxx/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)

trcalgaro commented 2 years ago

When I run it with the base64 image code it works! Could it be the problem in converting the image from the web link?

{ "success": true, "response": { "id": "4868772586554448", "isHidden": true, "catalogWid": "xxxxxxxxxx@c.us", "url": "https://www.google.com.br/", "name": "Teste API", "description": "Teste vindo da API", "availability": "unknown", "reviewStatus": "NO_REVIEW", "canAppeal": true, "currency": "BRL", "priceAmount1000": 17000, "retailerId": "000001", "imageCount": 1, "imageCdnUrl": "https://mmg.whatsapp.net/v/t45.5328-4/277846910_5842124802506832_4720980944146045509_n.jpg?ccb=1-5&_nc_sid=c48759&_nc_ohc=0PQgOS2ig1UAX-jVfia&_nc_ad=z-m&_nc_cid=0&_nc_ht=mmg.whatsapp.net&oh=01_AVwYB1fKFmiK1_iTWOY98aYQZqi4RbqPiO97pwFNCX-Kkg&oe=6255319C", "imageHash": "5842124795840166", "t": 1649385963.509, "productImageCollection": [ { "id": "_0", "mediaUrl": "https://mmg.whatsapp.net/v/t45.5328-4/277846910_5842124802506832_4720980944146045509_n.jpg?ccb=1-5&_nc_sid=c48759&_nc_ohc=0PQgOS2ig1UAX-jVfia&_nc_ad=z-m&_nc_cid=0&_nc_ht=mmg.whatsapp.net&oh=01_AVwYB1fKFmiK1_iTWOY98aYQZqi4RbqPiO97pwFNCX-Kkg&oe=6255319C", "fetchedFromServer": true } ], "fetchedFromServer": true } }

smashah commented 2 years ago

@trcalgaro Yes, for now it requires a base 64 image because it doesnt get the urls itself yet. I can implement that actually to make sure the format is correct using the same convenient logic in other methods like sendFile.

trcalgaro commented 2 years ago

I think it makes sense that you put yes, this will make it a lot easier.

I was trying because in the documentation it brings this possibility "Parameter: {string} images An array of dataurl or base64 strings of product images, the first image will be used as the main image. At least one image is required."

smashah commented 2 years ago

@github-actions run

⚡ Release! ⚡ ```js (async () => { function exec(cmd) { console.log(execSync(cmd).toString()); } //set the version type process.env.VERS = "patch" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`cd ./types-only && npm version $VERS && npm run build && npm publish && cd ..`); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 2 years ago

Changelog

🚀 Release 4.33.7 (2022-04-08)