Skip to content

More detail needed on setting HTTP headers #414

@lukewlms

Description

@lukewlms

I've read #186, but I'm still having trouble setting a header. I've created an httpClient but how do I "pass it in" here, is this supported?

As soon as I add this code (including without any header set), I get an error like this, which makes it seem like passing in the HTTP Header isn't working at all:

value": "

System.AggregateException: One or more errors occurred. (Unexpected character encountered while parsing value: <. Path '', line 0, position 0.)\n ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.\n   at

(My ultimate goal is to enable field truncation for a request, so we don't need to custom truncate every single field at the perfect length, per https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_header_allowfieldtruncation.htm.)

Here's the code. Note that I'm not sure this is the right header naming for this option, I haven't found SF documentation for setting it via HTTP:

    var httpClient = new HttpClient();
    httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Allow-Field-Truncation", "true");

    var client = new ForceClient(
      instanceUrl: auth.InstanceUrl,
      accessToken: auth.AccessToken,
      apiVersion: auth.ApiVersion,
      httpClient,
      httpClient
    );

(It looks like part of the issue I'm facing, at least, is the same as: #377)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions