Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

KeyError when evaluating

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
odooHelpdeskAutomatedActionsv16
1 Beantwoorden
1915 Weergaven
Avatar
Nathan

Hello, I have this code


def send_WA(self, name='', cid='', ticketid='', number='', templateWA='', user='', pw=''):
        todo = {
      	    "username": user,
            "password": pw
    	}
        headers= {
    	    "Content-Type":"application/json"
    	}
        r = requests.post("API URL",json.dumps(todo),headers=headers)
        response = r.json()
        jsonString=json.dumps(response)
        jsonObject=json.loads(jsonString)
        temp_token=jsonObject['jwt']['token']
        token=json.dumps(temp_token)
        token_final=token.strip('"')
        unique_token="Bearer " + token_final
        api_url="API URL" + templateWA
        todo1 = {
      	    "param":[name,cid,ticketid],
      	    "templateName":templateWA,
      	    "smsFallback":"false",
      	    "to": [number]
      	}
        headers1 = {
      	    "Content-Type":"application/json",
      	    "Authorization":unique_token
      	}
        response1 = requests.post(api_url, json.dumps(todo1), headers=headers1)
        r1 = response1.json()
        jsonString1=json.dumps(r1)
        jsonObject1=json.loads(jsonString1)
        temp_value = jsonObject1["data"][0]["status"]
        if temp_value == "failed":
            temp_value1 = jsonObject1["data"][0]["error"]
            if temp_value1 == "(#100) Invalid parameter":
                temp_value = "Invalid Phone Number"
        value = json.dumps(temp_value)
        final_value = value.strip('"')
        return final_value
And always get this error:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/tools/safe_eval.py", line 391, in safe_eval return unsafe_eval(c, globals_dict, locals_dict) File "ir.actions.server(606,)", line 7, in File "/opt/odoo/odoo-myrep/myrep_addon_ticketing/models/helpdesk_ticket.py", line 1236, in send_WA temp_value = jsonObject1["data"][0]["status"] KeyError: 'data'
ValueError: : "data" while evaluating
When I try to run the function manually (not from ODOO), it works and the response for jsonObject1 is as follows:

{'status': 200, 'data': [{'to': '+628********', 'messageId': '0ffb8cfb-be5d-447f-a002-*********', 'whatsappMessageId': 'wamid.HBgNNjI4OTYzNjEwNjI4MRUCABEYEj*******', 'status': 'sent'}], 'success': 1, 'failed': 0, 'msg': 'success'}

How to resolve this problem? thanks in advance


0
Avatar
Annuleer
Avatar
Niyas Raphy (Walnut Software Solutions)
Beste antwoord

Hi,
I hope you know that the error is coming as data key is missing in the variable jsonObject1 , this may be due to many reasons, for example lack for proper authentication etc

What you can do to solve the issue is try to execute the same code from the postman application, see if it works from there, if yes, take the python code from the postman and using that python code try to execute from odoo.

Thanks

0
Avatar
Annuleer
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Message Channel every time I validate a Receipts. Opgelost
odoo AutomatedActions
Avatar
Avatar
1
sep. 23
2031
How to use action = {} in automate actions, and give me some example with more explanation
odoo AutomatedActions
Avatar
0
dec. 22
3115
Automated action sends notification Opgelost
AutomatedActions V16 v16
Avatar
Avatar
Avatar
2
aug. 24
2591
v16: how to execute Automated Action on click of a button
button odoo AutomatedActions
Avatar
Avatar
1
jan. 24
5054
Automated Action that changes stage when customer replies
stages Helpdesk AutomatedActions
Avatar
Avatar
1
jul. 23
3480
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now