1

I'm trying to hit a Oauth2 secure Web API from a visual studio web test. I'm using a custom WebTestPlugin and custom WebTestRequestPlugin. The web test plugin simply gets the token from azure active directory and shoves into the request. That seems to be working just fine. I can see the outgoing request for the token comes back in fiddler. I use a web test request plugin to generate a json string string for the outgoing POST request to the API. I can't see that request getting fired off. I keep getting the error: Request failed: Specified value has invalid HTTP Header characters. Parameter name: name

custom Request plugin code

public override void PreRequest(object sender, PreRequestEventArgs e)
    {
        var body = new StringHttpBody
        {
            BodyString = EventBuilder.EventBuilder.BuildSingleAuditEvent(_orgId, _tenantId, _hashKey),
            ContentType = "application/json"
        };
        e.Request.Body = body;
    }

I'm using a service request in visual studio webtest with nothing in the String Body variable. enter image description here

as you can see the String Body has nothing set in its properties. enter image description here

here is the fiddler trace of the successful oauth request enter image description here

What am I missing here?

Mateo
  • 187
  • 1
  • 4
  • 15
  • What does the "Request" tab of the webtest results in Visual Studio show for the failing request? Fiddler's inspection panels will show the full contents (both header and body) of any request that is sent. What do the two plugins actually do (ie what is their code)? You say one works OK, so [edit] the question to show the code of the other one. – AdrianHHH Jan 26 '16 at 20:38

1 Answers1

1

this was an issue with formatting of the auth token. the header value was coming through as: "Authorization: Bearer", "TokenValue" when it should have been "Authorization:", "Bearer TokenValue"

Mateo
  • 187
  • 1
  • 4
  • 15