microsoft / microsoft/sql-server-samples

POST action results in "Invalid http header"

Open
#900 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
11.2k
Forks
9.1k
Avg merge
2d 7h
Merged PRs (30d)
14

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the request shown in the C# getObjects method and compare it with the working curl command. Confirm the intended request-header and response behavior against the API; the issue is done when the GET returns the requested metadata without header errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.