How to send image to Telegram Bot? - telegram-bot

Trying to send image (or any type of file) to telegram bot.
It possible to take blob, convert it to Base64 and POST it?
I've tried to test it via SOAPUI but:
https://api.telegram.org/botXXX/sendDocument
{
"chat_id":XXX,
"document":"R0lGODlhKAAoAMIAAAAAAL6+vgCYAOfn5wAA/wAAAAAAAAAAACH5BAEAAAEALAAAAAAoACgAAAPYGLrc/jDKSau9OOvNu19AKIafIxJoioplqL4vyQEwIdw1AWw0fAu52w5D+xlxNeOw0rMdjb6fztJ0PpEp6FJSDQKjqS2kNxigygQ0Do1Om6fc89tNX5vbdPhYnmKb7Xl5Yg00eHSGfipogwyFb3eQh5GPZowgkpiJmgMClgqOmZOibp1xbmWop6h+q5ylEWStkJSzq0ITsX1pWTd3fa6elzkqR1HBwsNWWFnHIMtRUi+vTNFJzysZANe8Nc0PXdLdHQDgOeQt5ObnJY3k7uvs8fLz9PX29/EJADs="
}
In that case response:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: wrong remote file identifier specified: Wrong character in the string"
}

You just had to send request with form-data)

Related

Error when uploading a video using instagram graph API

I want to upload a video using the instagram graph api however the API asks for an url (and not a local path) for the video parameter. The video I want to upload is on my desktop (local) so I don't know how I can convert it so it works.
When I put a local path instead of the url I get the following message:
`
{
"error": {
"message": "The video file you selected is in a format that we don't support.",
"type": "OAuthException",
"code": 352,
"error_subcode": 2207026,
"is_transient": false,
"error_user_title": "Unsupported format",
"error_user_msg": "The video format is not supported. Please check the specs for the supported streams format",
"fbtrace_id": "AA3qcWZCmMsp0OfEE_m1cLJ"
}
}
`

Strapi API register returning a 400 error

I’ve been creating a web app with a login and a registration function and so far everything has been going great. I managed to connect the app to the api/auth/local api endpoint and send some nice post requests.
Now, I’ve been trying to send requests to the http://localhost:1337/api/auth/local/register endpoint and without any success. I’ve been doing this according to:
https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html#registration
I keep getting a 400 error:
{
"data": null,
"error": {
"status": 400,
"name": "ApplicationError",
"message": "An error occurred during account creation",
"details": {
}
}
}
If I try to send a request with an email that’s already registered in strapi, the response will give me the correct error:
{
"data": null,
"error": {
"status": 400,
"name": "ApplicationError",
"message": "Email is already taken",
"details": {
}
}
}
In the public and authenticated user roles, I’ve allowed every single one of them, for now.
Enable confirmation emails are set to false.
Email confirmation
Public user permission
For the headers, I’m using Content-type : application/json
the raw json body I'm posting:
{
"email": "manager1#strapi.io",
"password": "testtest1",
"username": "manager1"
}
This is my first project with strapi and so far it went pretty well. I’m not sure if I’m missing out on something or if I’m doing something else wrong.
Any help is appreciated!
I figured it out, it wasn’t as complicated as I expected.
In the user I had different fields, like firstName, lastName etc. All of these fields were required.
I made the fields not required, and now it works.

Get error sending POST request to openweathermap via postman

I'm starting to learn the REST API. I use POSTMAN for this and openweathermap.org.
I am sending the name of the city in the body. The body has json format:
{
"cityName" : "Poltava,UA"
}
Response from the server:
{
"cod": "400",
"message": "Nothing to geocode"
}
Please tell me where I am going wrong? I changed the name of the key to "q", "city" and wrote simply "Poltava" and always I get the same error.
API docs: https://openweathermap.org/current
Headers of my request is:
Headers

A 400 error occurs when creating a OneDrive API upload session

Create an upload session to upload large files to oneDrive.
Below is the request address.
https://graph.microsoft.com/beta/users/{userId}/drive/root:/UploadFiles/{fileName}:/createUploadSession
Request Body
{
"item": {
"#odata.type": "microsoft.graph.driveItemUploadableProperties",
"#microsoft.graph.conflictBehavior": "rename",
"name": "largefile.dat"
}
}
An Invalid request error occurs. What's wrong with it? I watched the tutorial and tested it.
POST /drive/root:/{item-path}:/createUploadSession
Content-Type: application/json
{
"item": {
"#odata.type": "microsoft.graph.driveItemUploadableProperties",
"#microsoft.graph.conflictBehavior": "rename",
"name": "largefile.dat"
}
}
https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-beta#create-an-upload-session
As Shiva suggested in a comment on the question, the issue is that the value of #odata.type is not correct for this case. In general you should not provide it at all as the schema is strongly typed and therefore the appropriate value can be derived without any client-driven hints.

Quickblox, send push notification via REST API

When trying to send a push notification:
{'event[environment]': 'development', 'event[notification_type]': 'push', 'event[message]': u'payload=VGhpcyBpcyBhIHB1c2ggbm90aWZpY2F0aW9uIEFQSSBUZXN0', 'event[user][ids]': 'xxx', 'token': xxx'}
I get following result from the API.
{"code":null,"message":"invalid byte sequence in UTF-8"}
The Payload is a base64 encoded string, so it should work properly. Anyone an idea what's wrong here?
thanks,
phil
It looks like your message is not in the correct format:
Did you encode a JSON Object like the following one as Base64 ?
"aps": { "alert": "Some text", "badge": 1, "sound": "default" }