bad-request

How can I customize HTTP 400 responses for parse errors?

天涯浪子 提交于 2019-12-04 07:44:46
I've written a REST API service that requires that all responses be JSON. However, when the Go HTTP request parser encounters an error, it returns 400 as a plain text response without ever calling my handlers. Example: > curl -i -H 'Authorization: Basic hi there' 'http://localhost:8080/test' -v * Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8080 (#0) > GET /test HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.54.0 > Accept: */* > Authorization: Basic hi > there > < HTTP/1.1 400 Bad Request HTTP/1.1 400 Bad Request < Content-Type: text/plain; charset=utf-8 Content

Telegram Bot API: getChatMember throws USER_ID_INVALID for valid user

女生的网名这么多〃 提交于 2019-12-04 07:34:39
I'm trying to find out if a specific User is present in a supergroup, in order to keep track of those who left. For that, I'm calling the Bot API method getChatMember for each User and checking if their status is either Left or Kicked . However, I noticed that (recently?) I'm getting USER_ID_INVALID errors for many valid users that are either in the supergroup or have been in the past and then left. I also confirmed that those accounts are still active on Telegram. Here's the HTTP request I'm sending: POST https://api.telegram.org/botXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXX/getChatMember HTTP/1.1

Django and Bad Request (400)

蹲街弑〆低调 提交于 2019-12-03 19:22:35
I created new django project; added to my settings.py: DEBUG = False ALLOWED_HOSTS= [ 'localhost', 'my_site.com' ] created app test_view ; added hello_world to test_view.views from django.http.response import HttpResponse def hello_world(request): return HttpResponse('Hello World!!!') added test route to urls.py url(r'test/', 'test_view.views.hello_world') ; fixed /etc/hosts 127.0.0.1 localhost my_site.com Now when i'm trying to access http://my_site.com:8000/test/ django returns Bad Request (400). But when url is http://localhost:8000/test/ I can see my Hello World page. What can be wrong?

PHP Bad Request in Curl on SOAP interface of http://www.cyberlogic.gr/webservices/PlaceSearch

孤街浪徒 提交于 2019-12-02 12:53:34
I am trying to call the url using curl in php. I get a BAD REQUEST error . if someone can help me,I do not get what the problem is Their "recipe" is as follows: http://wl.filos.com.gr/services/WebService.asmx?op=PlaceSearch (look at soap 1.1) The code I have is: <? // xml data $soap_request = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $soap_request .= "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"; $soap_request .= " <soap:Body>\n"; $soap_request .= "

URLConnection always returns 400 : Bad Request when I try to upload a .wav file

馋奶兔 提交于 2019-12-02 10:13:18
I want to implement some code that does exactly what I accomplish when I execute a CURL command in my Mac's terminal, which is to upload a .wav file to a Server. I already accomplished this for one server before, so my general thinking works (and my code too), ....but now I want to accomplish the same but on a different server. This time I am having trouble and all I get are "400:Bad Request" This is he CURL command I want to do on Android, I have added a "-v" so you can see the verbose of my command. curl -F file=@audio_life.wav 11.2.333.44:14141/transcribe -v Output log in Terminal: * Trying

HTTP 400 error in REST web service during POST with FormParam containing own objects (e.g. enities)

徘徊边缘 提交于 2019-12-01 06:48:24
For an ordering process in my REST service I have to send a list of "articles" from client to server. These article objects are of a self-made entity type. I already found out that sending a list of STRING or INTEGER objects does work, sending it via @FormParam. But as soon as I try to send a list of my own objects (even only ONE object), I always get a HTTP 400 error "Bad Request" . I tried excatly the same code like below (only the parameters of form.add() and the parameters of the server method were altered) and postet Strings, Integers and lists of Strings successfully. It only makes

HTTP 400 error in REST web service during POST with FormParam containing own objects (e.g. enities)

徘徊边缘 提交于 2019-12-01 05:20:32
问题 For an ordering process in my REST service I have to send a list of "articles" from client to server. These article objects are of a self-made entity type. I already found out that sending a list of STRING or INTEGER objects does work, sending it via @FormParam. But as soon as I try to send a list of my own objects (even only ONE object), I always get a HTTP 400 error "Bad Request" . I tried excatly the same code like below (only the parameters of form.add() and the parameters of the server

Trying to search Sharepoint files using Microsoft Graph api

我怕爱的太早我们不能终老 提交于 2019-11-30 16:06:53
We are using the Microsoft Graph API (new, Office365 unified API renamed to this recently). We have an OAUTH login, with the graph.microsoft.com resource used to generate a token. It works fine to get other subresources such as /me . But when using the URL in Microsoft Graph's documentation that talks about searching drive (and SharePoint?) we cannot find a way to make any sample URL work. It doesn't work when a drive is available for the user nor when SharePoint. So first question, why does this generate an error? GET https://graph.microsoft.com/v1.0/drive/root/Microsoft.Graph.search?q=img

Guzzle: handle 400 bad request

我的梦境 提交于 2019-11-30 03:46:06
I'm using Guzzle in Laravel 4 to return some data from another server, but I can't handle Error 400 bad request [status code] 400 [reason phrase] Bad Request using: $client->get('http://www.example.com/path/'.$path, [ 'allow_redirects' => true, 'timeout' => 2000 ]); how to solve it? thanks, As written in Guzzle official documentation: http://guzzle.readthedocs.org/en/latest/quickstart.html A GuzzleHttp\Exception\ClientException is thrown for 400 level errors if the exceptions request option is set to true For correct error handling I would use this code: use GuzzleHttp\Client; use GuzzleHttp

Google Calendar API - Bad Request (400) Trying To Swap Code For Access Token

大兔子大兔子 提交于 2019-11-29 18:00:58
Having got an authorisation code from Google for accessing a user's calendar, I'm now trying to swap this for an access token. According to their own docs: The actual request might look like: POST /o/oauth2/token HTTP/1.1 Host: accounts.google.com Content-Type: application/x-www-form-urlencoded code=4/v6xr77ewYqhvHSyW6UJ1w7jKwAzu& client_id=8819981768.apps.googleusercontent.com& client_secret={client_secret}& redirect_uri=https://oauth2-login-demo.appspot.com/code& grant_type=authorization_code My attempt to access this is as follows (C#): string url = "https://accounts.google.com/o/oauth2