Project 11 error 401

Can somebody let me know the error please i couldnt understand the error

Plz somebody let me know the error i had written code correctly without error

@yashdadi872 you must have encountered a syntactical error while printing the statement in Line 58. In your code you can see that you have written after " the current value is" and the sign $ also tells that the line is not ending here, so you might have written something wring at the end. You have also used ‘/’ in that print statement which is not necessary. You must have copied the code directly from the training content. There the / was just an intimation that the line is in continuity.

So, I suggest you to write two statements so that you can see the syntax of both. Write in this following manner:

print("Alert! Sensor value has exceeded " + str(conf.threshold))
print(“The current value is” + str(temp))

This will solve your problem :slight_smile:

1 Like

but here i should not print it rgt…instead i need to store it in message na

Okay. I missed that thing.

part1 = "Alert! Sensor value has exceeded " + str(conf.threshold)
part 2 = “ The current value is” + str(temp)

Then in the next statement, concat the 02 strings and pass them in the send_tel_msg() in this manner:
telegram_status = send_tel_msg(part1,part2)

1 Like

bro that is solved a new error came…i removed \ and it worked
a new error with error 404 came

Okay then just remove the / in your message string.

The message string should look like this:

message = "Alert! Sensor value has exceeded " + str(conf.threshold) + “. The current value is” + str(temp)

1 Like

Okay. This error is due to the incorrect telegram credentials. Re check those

1 Like

i checked it they r rgt but i have a doubt
can u tell me clearly that what comes under telegram chat id and what comes under telegram bot id

like if my bot username is for eg: “ab_bot”…then my bot id shud be “botabt_bot” right
and if my telegram channel name is “abc def” then its id shud be “@abc def” is that crct

In the conf file, you should have the following parameters:

bolt_api_key = “XXXXX”
device_id = “BOLTXXXXX”
telegram_chat_id = “@XXX
telegram_bot_id = “botXXX”
threshold = 250

The telegram_bot id is generally the string having bot keyword and then the token id of the bot

for eg: bot894346529:AAH (complete the string with the token)

telegram_chat_id can be in the channel info:
In this case, telegram_chat_id is @temperature_alert

1 Like

@yashdadi872 I hope you get it now :slight_smile:

1 Like

yeah got it bro but now its error 401…

@yashdadi872 just replace the line 58 with this:

message = "Alert! Sensor value has exceeded " + str(conf.threshold) + “. The current value is” + str(temp)

You have unnecessarily used a back slash there

1 Like

yeah i wrote in the same way but no change

Brother as after correcting the statement you are not getting the previous error. It means that the problem is solved.

Now you are getting 404 error which implies you have some error in the telegram credentials.

Do share the ss of conf file and just hide the api key and device id

1 Like

Its 401 bro…will u

See this bro

The HTTP 401 Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.

I can only tell you to confirm the Token because authentication is not able to be formed.

The telegram chat id is presented in the link after

The chat id is @verstaile_bolt

1 Like

Both were same na

@yashdadi872 in the config file use the double quotes for every variable string. This might solve the problem

1 Like

no bro not yet solved