2

How do I set an empty body for my get request without leaving out the Body parameter?

See the following example:

url <- "https://www.capitalonecareers.com/search-jobs/results?ActiveFacetID=0&CurrentPage=3&RecordsPerPage=15&Distance=50&RadiusUnitType=0&Keywords=&Location=&Latitude=&Longitude=&ShowRadius=False&CustomFacetName=&FacetTerm=&FacetType=0&SearchResultsModuleName=Search+Results&SearchFiltersModuleName=Search+Filters&SortCriteria=0&SortDirection=1&SearchType=5&CategoryFacetTerm=&CategoryFacetType=&LocationFacetTerm=&LocationFacetType=&KeywordType=&LocationType=&LocationPath=&OrganizationIds=&PostalCode=&fc=&fl=&fcf=&afc=&afl=&afcf="
GET(url = url, verbose())$headers$`content-length`

I get a result with Content length of 9125.

How can I do the equivilant with Setting a Body Parameter:

GET(url = url, body = NULL, verbose())$headers$`content-length`

(Has Status Code = 200, but no results besides an empty JSON – > Content length of 55).

What I tried:

Code:

GET(url = url, body = list() verbose())$headers$`content-length`
GET(url = url, body = "", verbose())$headers$`content-length`
GET(url = url, body = NULL, verbose())$headers$`content-length`
GET(url = url, body = c(), verbose())$headers$`content-length`
  • Examine the results from verbose(), see the Code above. But I don't see any differences for the request being sent.

Why I want to do it:

For some code (with dynamic request Methods) it seems easier to specify an empty Default value instead of adding an if Statement and adding a Body Parameter if one is present or leaving it out in case it is not needed.

I am aware that a Body should/would not have an Impact in a get request, see e.g. https://stackoverflow.com/a/983458/3502164. And for this question that would be the case.

Tlatwork
  • 1,445
  • 12
  • 35

0 Answers0