Skip to content

Not possible to pass a body in a GET request ? #1764

Open

Description

@mhuijser

Hi there !

I'd like to upgrade my project to use jsForce-lib version 3 (coming from version 1). We're using a nodejs based api, so i found it would be best to implement @jsforce/jsforce-node

While implementing the API, which we call by using the request method of the Connection, i ran into the issue that i can't find any way to pass a body correctly when issuing a GET request.

Code:

  import jsforce from '@jsforce/jsforce-node'
  
  import type { Connection, HttpRequest, HttpMethods } from '@jsforce/jsforce-node'
  
  ....

  const api = await login()  // 'api' is in our case the jsforce Connection which we obtain by invoking login()

  const httpRequest: HttpRequest = {
    url: path,
    method: method as HttpMethods,   // <-- which is in this case 'GET'
    body: JSON.stringify(body),    // <-- we should pass a stringified JSON
    headers: {
      'content-type': 'application/json',
    },
  }
  const res = await api.request(httpRequest, {   
    retry: { maxRetries: 0 },
  })

  ....

This resulted in an APEX error on de salesforce-API we're trying to implement.

Debugging the Salesforce counterpart of the call, we found that the body is a BLOB (0 bytes):

headers = '0x6cddb34d'
httpMethod = 'GET'
params = '0x386ae118'
remoteAddress = 'XXX.XXX.XXX.XXX'
requestURI = '/account/info'
resourcePath = '/services/apexrest/a (8 more) ...'
requestBody = BLOB(0 bytes)

Of course i've double-checked if i'm actually passing a valid stringified JSON ;-)

Am i doing anything wrong ? Or doesn't the library support a body on a GET request anymore ?

I hope you might help me out....

Thanks in advance,

Mark

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions