HTTP use body options in Get Method
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior Http using get method and pass body with options does not work.
Expected/desired behavior Please correct it to use body in method get. This is ok to post method but not to get method
Reproduction of the problem
This is my scenario
export class BuscaVagasService { private _rota = ‘http://localhost:49571/api/v0/busca-vagas’;
constructor(private _http: Http) { }
getVagas(dados: { [chave: string]: string[]; }): Observable<IResultadoBusca<IVaga>> {
let body = JSON.stringify(dados);
let headers = new Headers({ 'Content-Type': 'application/json' });
var requestOptions = new RequestOptions({
headers: headers,
body: dados
})
let retorno = this._http.get(this._rota, requestOptions)
.map((response: Response) => response.json() || {});
return retorno;
}
What is the expected behavior?
pass body to webApi Method
What is the motivation / use case for changing the behavior?
To correct this
Please tell us about your environment:
-
Angular version: 2.0.0-rc.4
-
Browser: [ Chrome 51.0.2704.103 ]
-
Language: [TypeScript]
-
**Web Api: .NET Core:
[HttpGet] public ResultadoBusca<Vaga> Buscar([FromBody]Dictionary<string, List<string>> dados = null, [FromQuery]bool comFacets = true) { var parametros = this._buscaVagaService.ParsearArgumentos(dados); return this._buscaVagaService.Buscar(parametros, comFacets); }
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
HTTP GET with request body - Stack Overflow
Yes, you can send a request body with GET but it should not have any meaning. If you give it meaning by parsing...
Read more >GET - HTTP - MDN Web Docs
The HTTP GET method requests a representation of the specified resource. Requests using GET should only be used to request data (they ...
Read more >Request bodies in GET requests - Evert Pot
So if we decided to use GET for our complex search, what can we do? Body is obviously not allowed; our only options...
Read more >HTTP GET with Request body - Guidelines - TheCodeBuzz
HTTP GET with Request body guidelines and best practices . Specification clarifies support for GET method with body parameters with known ...
Read more >REST API - HTTP GET with Request Body - Roy Tutorials
Here I am going to discuss about whether it is a good idea to send parameter in request body of the HTTP GET...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is as designed. HTTP Get does not support body and hence the Angular’s Http does not support it either
IIRC the RFC does not prevent GET request from having a body but in practice most servers do not support this.