• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Node.js SDK)
  4. Troubleshooting
  5. SDK Common Result Object

SDK Common Result Object

After you call an API in an instance of the ObsClient class, a common result object will be returned if the exception information parameter is null. The following table lists the fields of the object:

Field

Type

Description

CommonMsg

Object

Common information generated after the API is called, including HTTP status code and error code.

  

Status

Number

HTTP status code. If the value is smaller than 300, the operation succeeds. Otherwise, the operation fails.

Code

String

Error code returned by the OBS server. If Status is smaller than 300, the value is null.

Message

String

Error description returned by the OBS server. If Status is smaller than 300, the value is null.

HostId

String

Requested Server ID. If Status is smaller than 300, the value is null.

RequestId

String

Request ID returned by the OBS server. If Status is smaller than 300, the value is null.

InterfaceResult

Object

Result data generated after the operation is successful. If Status is greater than 300, the value is null.

  

RequestId

String

Request ID returned by the OBS server.

Other fields

See the API reference.

Sample code:

// Import the OBS library.
var ObsClient = require('./lib/obs');

// Create an instance of ObsClient.
var obsClient = new ObsClient({
    access_key_id: '*** Provide your Access Key ***',       
    secret_access_key: '*** Provide your Secret Key ***',       
    server : 'yourdomainname'
});

// Call APIs to perform operations, such as downloading an object.
obsClient.getObject({
       Bucket : 'bucketname',
       Key : 'objectkey',
}, (err, result) => {
       if(!err){
              if(result.CommonMsg.Status < 300){
                     // Obtain RequestId.
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
                     // Obtain other parameters.
                     console.log('Content-->' + result.InterfaceResult.Content.toString());
              }else{
                     // Obtain Code and Message.
                     console.log('Code-->' + result.CommonMsg.Code); 
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});