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.15k stars 600 forks source link

API Error: Unable to Post Poll Due to Incorrect Argument Parsing #3220

Open pavankpdev opened 5 months ago

pavankpdev commented 5 months ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Legacy (Normal)

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

Personal account (normal)

Mode

EASY API/CLI

Current Behavior

I'm trying to call the /sendPoll API from Swagger, but it fails with the following error:

Request Body

{
    "args": {
        "to": "****************@g.us",
        "name": "Where shall we eat?",
        "options": [
            "Pizza Express",
            "Pizza Hut",
            "Pizza Fusion"
        ],
        "allowMultiSelect": false
    }
}

Response

{
    "success": false,
    "error": {
        "name": "Error",
        "message": "Please set arguments in request json body, not in params. Evaluation failed: TypeError: _0x3037c7[(_0x2267e9(...) + \"FE\")](...) is not a function\n    at window.<computed>.<computed> [as sendPoll] (pptr://__puppeteer_evaluation_script__:1:655267)\n    at pptr://__puppeteer_evaluation_script__:2:29"
    }
}

I tried the same request with Postman and cURL, and the result is the same error.

Expected Behavior

The expected behavior is that the API should successfully post a poll in my group chat, allowing group members to vote on where we should eat.

Steps To Reproduce

  1. Run npx @open-wa/wa-automate -w https://webhook.site/87c9b01e-ba82-415a-9d0e-af6cabd4f2ce -p 8008
  2. Open swagger docs at http://localhost:8008/api-docs/#/default/post_sendPoll
  3. Try to call sendPoll API

create() code OR full CLI command + CONFIG

npx @open-wa/wa-automate -w https://webhook.site/87c9b01e-ba82-415a-9d0e-af6cabd4f2ce -p 8008

DEBUG INFO

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index)             β”‚ Values                                                                                                                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ WA_VERSION          β”‚ '2.3000.1014228662'                                                                                                                        β”‚
β”‚ PAGE_UA             β”‚ 'WhatsApp/2.2147.16 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36' β”‚
β”‚ WA_AUTOMATE_VERSION β”‚ '1.0.0'                                                                                                                                    β”‚
β”‚ BROWSER_VERSION     β”‚ 'HeadlessChrome/112.0.5614.0'                                                                                                              β”‚
β”‚ OS                  β”‚ 'macOS Unknown'                                                                                                                            β”‚
β”‚ START_TS            β”‚ 1718387007090                                                                                                                              β”‚
β”‚ RAM_INFO            β”‚ 'Total: 17.18 GB | Free: 1.88 GB'                                                                                                          β”‚
β”‚ PPTR_VERSION        β”‚ '19.11.1'                                                                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Environment

- OS: MacOS
- Node: v21.7.3
- npm: 10.5.0

Screenshots/Logs

image

Anything else?

Additional Attempts

I also tried sending the request using Postman and cURL with the same request body, but I encountered the same error message each time. It seems the API is not accepting the arguments as they are currently structured in the request body.

smashah commented 4 months ago

when was the last time you tried this? im unable to replicate the problem

pavankpdev commented 4 months ago

@smashah I tried this two weeks ago, please try to call the API to send Poll to replicate this issue. I used the CLI to bootstrap the project

Both sending poll and reason the poll API doesn't work.

pavankpdev commented 4 months ago

@smashah I tried the same using the docker version of openwa, I get this below error when I try sendPoll

Body

{
  "args": {
    "to": "919686855796@g.us",
    "name": "string",
"localId": "123",
    "options": ["dad", "DAdad"],
    "allowMultiSelect": "boolean"
  }
}

Response

{
  "success": false,
  "error": {
    "name": "TypeError",
    "message": "Please set arguments in request json body, not in params. Cannot read properties of undefined (reading 'id')\nj (https://static.whatsapp.net/rsrc.php/v3i8Ri4/yB/l/rt/HOH2o6x2WEY.js?_nc_x=Ij3Wp8lg5Kz:172:1135)\nObject.<anonymous> (https://static.whatsapp.net/rsrc.php/v3i8Ri4/yB/l/rt/HOH2o6x2WEY.js?_nc_x=Ij3Wp8lg5Kz:172:561)"
  }
}