microsoft / microsoft/sql-server-samples

POST action results in "Invalid http header"

Aperta
#900 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
PowerShell
Stelle
11.2k
Fork
9.1k
Merge medio
2g 7h
PR unite (30g)
14

Descrizione

I am trying to execute a GET command so I get can get data from a server. The Curl below works in Postman.

$ curl -X GET -H "Authorization: {SESSION_ID}"
https://{server}/api/{version}/metadata/vobjects
While running my code, I am able to get the session ID. The next step is to get the data. But when I execute the GET, I don't get any response. Instead a I get an error as follows: "Specified value has invalid HTTP Header characters. (Parameter 'name')"

Below is the C# code I am trying to execute

_

public static void getObjects(string sessionID)
{
var client = new RestClient("https://generic-server.com/api/v20.3/metadata/vobjects/");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization:", sessionID);
IRestResponse response = client.Execute(request);
Console.WriteLine("Here's the response: " + response.Content + " " + response.Content.Length);
Console.WriteLine("Here's the error message: " + response.ErrorMessage);
}

_

response.ErrorMessage gives the following:

Here's the error message: Specified value has invalid HTTP Header characters. (Parameter 'name')

Note: When I leave the colon out of of the header, then I get the following response from the server:

{"responseStatus":"FAILURE","errors":[{"type":"INVALID_DATA","message":"Invalid http header [Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml]"}]} 190

Does anyone have any thoughts

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo la richiesta mostrata nel metodo getObjects in C# e confrontala con il comando curl funzionante. Conferma il comportamento previsto degli header della richiesta e della risposta rispetto all’API; l’issue è completata quando il GET restituisce i metadati richiesti senza errori degli header.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.