jsforce / jsforce/jsforce

Not possible to pass a body in a GET request ?

Open
#1,764 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
551
Avg merge
9h 2m
Merged PRs (30d)
3

Description

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

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

The issue names Connection.request and @jsforce/jsforce-node but no source file or test. Start by tracing the supplied HttpRequest through that request entry point and reproducing the GET call; done means the library's GET-body behavior is established and covered or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.