Skip to content

Unable extract partial response in sample client code unlike API Explorer #1494

Closed
@bhsiaoNFLX

Description

@bhsiaoNFLX

The API Explorer lets you specify the fields request parameter (under "Show standard parameters") to specify which fields to include in the partial response. In particular, I am interested in getting back the spellCorrection partial response using the sample code provided. My question applies to the broader issue that the sample client code doesn't seem to support extracting partial responses like the API explorer does, but I will use spellingCorrection for the following examples:

// passing "fields: spellCorrection" as a second argument
client.searchJob(request, { fields: "spellCorrection" })

// passing "spellCorrection: true" as a second argument
client.searchJob(request, { spellCorrection: true })

// passing "fields: spellCorrection" within the request
var request = {
   parent: "...",
   requestMetadata: {...}
   fields: {
      spellCorrection: true
   }
}
client.searchJob(request)

// passing "spellCorrection: true" within the request
var request = {
   ...
   spellCorrection: true
}
client.searchJob(request)

All the above the variations I've tried but they don't seem to work.

Looking at the implementation of searchJobs within job_service_client.js it is unclear how I can pass in spellingCorrection as a parameter.

Alternatively, is there an easy way I can modify job_service_client.js to return the spellingCorrection partial response, or am I out of luck?

Note: I am getting a proper response back with the matching jobs in the form of an array:

[
   [{<matching_job_1>},{<matching_job_2>}...],
   null,
   null
]

versus in the API Explorer I get a json:

{
  "matchingJobs:": [{<matching_job_1>},{<matching_job_2>}...]
  "spellCorrection": {
    "corrected": true,
    "correctedText": "engineer"
  }
}

Metadata

Metadata

Assignees

Labels

type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions