Comments (9)
Yes all info are guaranteed to be correct.
Because this will work:
let bot = LineBot::new(channel_secret.as_str(), access_token.as_str());
let mut messages: Vec<SendMessageType> = Vec::new();
messages.push(SendMessageType::TextMessage(TextMessage {
text: String::from("Pushed"),
emojis: None,
}));
let result = bot.push_message(line_id, messages);
But this will fail with that error:
let bot = LineBot::new(channel_secret.as_str(), access_token.as_str());
let mut messages: Vec<SendMessageType> = Vec::new();
let res = bot.get_profile(line_id);
let _profile = res.unwrap();
messages.push(SendMessageType::TextMessage(TextMessage {
text: String::from("Pushed"),
emojis: None,
}));
let result = bot.push_message(line_id, messages);
from line-bot-sdk-rust.
I think it might a bug in the http client or reqwest http client lib (maybe a thread or socket race condition?).
When debugging, if I step slowly through each function in the debugger, the push_message call will be successful.
Running normally will always get 400.
Hope this info is useful
from line-bot-sdk-rust.
thanks @axblueblader
please show me the error message when it fails.
from line-bot-sdk-rust.
Hi @nanato12 , here is the response log
I set log level to TRACE but that's all I got, sorry, couldn't find other useful error message.
It just works properly when remove bot.get_profile
call
Ok(Response { url: Url { scheme: "https", username: "", password: None, host: Some(Domain("api.line.me")), port: None, path: "/v2/bot/message/push", query: None, fragment: None
}, status: 400, headers: {
"server": "AkamaiGHost",
"mime-version": "1.0",
"content-type": "text/html",
"content-length": "216",
"expires": "Thu, 15 Apr 2021 06:36:28 GMT",
"date": "Thu, 15 Apr 2021 06:36:28 GMT",
"connection": "close"
}
})
from line-bot-sdk-rust.
add "println" and check the response message.
and show me.
let result = bot.push_message(line_id, messages);
println!("{:?}", result.unwrap().text());
UserID length is 33.
if length is not 33 or "Uxxxxxx" (x is hex) , response is Ok("{\"message\":\"The property, \'to\', in the request body is invalid (line: -, column: -)\"}")
.
if UserID is invalid, response is Ok("{\"message\":\"Failed to send messages\"}")
from line-bot-sdk-rust.
println!("user id length: {:?}", line_id.len());
let _res = bot.push_message(line_id, messages);
println!("bot.push_message: {:?}", _res.unwrap().text());
Length is 33
Here is response text
Ok("<HTML><HEAD>\n<TITLE>Bad Request</TITLE>\n</HEAD><BODY>\n<H1>Bad Request</H1>\nYour browser sent a request that this server could not understand.<P>\nReference #7.6fb42d17.1618478740.0\n</BODY>\n</HTML>\n")
from line-bot-sdk-rust.
LINE_CHANNEL_SECRET
and LINE_CHANNEL_ACCESS_TOKEN
correct?
from line-bot-sdk-rust.
thanks @axblueblader
It works without any trouble in my environment.
I don't know the exact cause.
Sorry....
from line-bot-sdk-rust.
ye, it could be the Rust version or something
anyways thanks for looking into it
from line-bot-sdk-rust.
Related Issues (8)
- HTTPClient RequestBuilder must use method.query
- TODO: FlexMessage struct
- TODO: RichMenu
- When is the next release that will have 'actix_support' feature included? HOT 1
- `SouceType` should `SourceType` HOT 1
- Call to `get_content()` returns status 404.
- use of deprecated function `base64::encode`: Use Engine::encode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from line-bot-sdk-rust.