Skip to Main Content

API, CLI, SDK & Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create a Bastion port forwarding session with Node API

user-kpo8bOct 2 2023

Hi community,

I'm trying to create a port forwarding session using this sample but getting “errorObject: OciError: Missing Parameter”, below my code and the response, what am I doing wrong ?

Code:

const provider = new common.ConfigFileAuthenticationDetailsProvider();

const bastionClient = new bastion.BastionClient({ authenticationDetailsProvider: provider });

// Create the target resource details object

const fileContent = fs.readFileSync(filePath, 'utf8');

const targetResourceDetails = JSON.parse(fileContent);

// Create a request and dependent object(s).

const createSessionDetails = {

displayName: "Session-" + user.toLowerCase() + "-" + portStart + "-" + new Date().toISOString().slice(0, 16).replace(/[-:T]/g, ""),

bastionId: BASTIONID,

targetResourceDetails: targetResourceDetails,

keyType: bastion.models.CreateSessionDetails.KeyType.Pub,

keyDetails: {

publicKeyContent: "ssh-rsa …"

},

sessionTtlInSeconds: 10800

};

console.log("req: ", createSessionDetails);

// create the session

const createSessionRequest = bastion.requests.CreateSessionRequest = {

createSessionDetails: JSON.stringify(createSessionDetails)

};

const createSessionResponse = await bastionClient.createSession(createSessionRequest);

Response:

error from defaultErrorFunction: {
response: Response {
[Symbol(realm)]: null,
[Symbol(state)]: {
aborted: false,
rangeRequested: false,
timingAllowPassed: true,
requestIncludesCredentials: true,
type: 'default',
status: 400,
timingInfo: [Object],
cacheState: '',
statusText: 'Bad Request',
headersList: [HeadersList],
urlList: [Array],
body: [Object]
},
[Symbol(headers)]: HeadersList {
cookies: null,
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
}
},
errorObject: OciError: Missing Parameter
at Object.handleErrorResponse (/tmp/pfw-oci/node_modules/oci-common/lib/helper.js:34:16)
at Function.<anonymous> (/tmp/pfw-oci/node_modules/oci-common/lib/circuit-breaker.js:30:50)
at Generator.next (<anonymous>)
at fulfilled (/tmp/pfw-oci/node_modules/oci-common/lib/circuit-breaker.js:9:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
statusCode: 400,
serviceCode: 'MissingParameter',
opcRequestId: '…',
targetService: 'Bastion',
operationName: 'createSession',
timestamp: '2023-10-01T22:33:48.055Z',
requestEndpoint: 'POST https://bastion.ap-singapore-1.oci.oraclecloud.com/20210331/sessions',
clientVersion: 'Oracle-TypeScriptSDK/2.70.1',
loggingTips: 'To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdkconcepts.htm#typescriptsdkconcepts_topic_Logging for ways to log the request/response details.',
troubleshootingTips: "See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_400__400_missingparameter for more information about resolving this error Also see https://docs.oracle.com/iaas/api/#/en/bastion/20210331/Session/CreateSession for details on this operation's requirements. If you are unable to resolve this Bastion issue, please contact Oracle support and provide them this full error message."
}
}

Comments
Post Details
Added on Oct 2 2023
0 comments
432 views