Mailgun Email Error : Extra Data

Mailgun Showing Error

To resolve this issue, first, check your API request and ensure that all required parameters are included and formatted correctly. Make sure that the payload is properly formatted as JSON and does not contain any extra data that is not recognized by the server.

Let us know if your query resolved

1 Like

Bellow is my code could you please tell me where is the problem. I couldn’t recognized the problem…

Can you share the code so we can assist you.

**Bellow is my code**
:face_holding_back_tears: :face_holding_back_tears:

import email_conf
from boltiot import Email, Bolt
import json, time

min= 300
max= 600

mybolt Bolt (email_conf.API_KEY, email_conf.DEVICE_ID)
mailer Email(email_conf.MAILGUN_API_KEY, email_conf. SANDBOX_URL, email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL)

while True:
print (ā€œReading Sensor Valueā€)
response= mybolt.analogRead(ā€˜A0’)
data= json. loads (response)
print ("Sensor value is "+str(data[ā€˜value’]))
try:
sensor_value=int(data[ā€˜value’])
temperature=(100xsensor_value)/1024
if sensor_value>max or sensor_value <min:
print(ā€œMaking request to Mailgun to send emailā€)
response-mailer.send_email(ā€œAlertā€, "The current temperature is "+str(temperature))
response_text = json. loads (response.text)
print ("Response recived from Mailgun is "+str(response_text [ā€˜message’]))
except Exception as e:
print(ā€œError occured bellow are the detailesā€)
print (e)
time.sleep(10)

The code is encountering multiple errors, some of which are:

Typographical errors:

Incorrect usage of quotes: The quotes used in the code are not standard quotes, which are causing a syntax error. Use either single quotes (’ ') or double quotes (" ") instead of the quotes used in the code.
Incorrect use of equals sign: The equals sign = is being used instead of the minus sign - in the following line: response-mailer.send_email(ā€œAlertā€, "The current temperature is "+str(temperature)).
Naming errors:

Incorrect class instantiation: The class instantiation for Bolt and Email is missing the = sign. Use mybolt = Bolt(email_conf.API_KEY, email_conf.DEVICE_ID) and mailer = Email(email_conf.MAILGUN_API_KEY, email_conf.SANDBOX_URL, email_conf.SENDER_EMAIL, email_conf.RECIPIENT_EMAIL).

Incorrect variable names: The variable name min shadows the built-in function min(), which is not recommended. Rename the variable to a more meaningful name, like min_value.
Incorrect mathematical operation:

The multiplication operator * is being represented as the letter x, causing a syntax error. Change 100xsensor_value to 100 * sensor_value.

1 Like

I changed accordingly but problem is not solved