2016-09-20 7 views
0

인증주기에서 잘못된 작업을하고 있지만 계속 500 초를 유지하고 있으며 메시지가 매우 모호합니다.상자 노드 API 폴더 정보를 가져올 수 있지만 폴더를 만들 수 없음

그래서 노드 서버에서 상자를 호출합니다. 내가 돌아 얻을

export function yearEnd(req, res) { 
    req.sdk.folders.create({ 
    name: 'test', 
    parent: { 
     id: '0', 
    }, 
    }, (e, r) => { 
    if (e) { 
     return res.send(e); 
    } 
    return res.status(201).send(r); 
    }); 
} 

응답 :

{ 
    "request": { 
     "uri": { 
      "protocol": "https:", 
      "slashes": true, 
      "auth": null, 
      "host": "api.box.com", 
      "port": 443, 
      "hostname": "api.box.com", 
      "hash": null, 
      "search": null, 
      "query": null, 
      "pathname": "/2.0/folders", 
      "path": "/2.0/folders", 
      "href": "https://api.box.com/2.0/folders" 
     }, 
     "method": "POST", 
     "headers": { 
      "User-Agent": "Box Node.js SDK v1.0.0", 
      "Authorization": "[REMOVED BY SDK]", 
      "accept": "application/json", 
      "content-type": "application/json", 
      "content-length": 75 
     } 
    }, 
    "response": { 
     "statusCode": 500, 
     "body": { 
      "type": "error", 
      "status": 500, 
      "code": "internal_server_error", 
      "help_url": "http://developers.box.com/docs/#errors", 
      "message": "Internal Server Error", 
      "request_id": "29462704457e0f3876ee08" 
     }, 
     "headers": { 
      "server": "ATS", 
      "date": "Tue, 20 Sep 2016 08:29:59 GMT", 
      "content-type": "application/json", 
      "content-length": "188", 
      "cache-control": "no-cache, no-store", 
      "strict-transport-security": "max-age=31536000; includeSubDomains", 
      "vary": "Accept-Encoding", 
      "age": "0", 
      "connection": "keep-alive" 
     }, 
     "request": { 
      "uri": { 
       "protocol": "https:", 
       "slashes": true, 
       "auth": null, 
       "host": "api.box.com", 
       "port": 443, 
       "hostname": "api.box.com", 
       "hash": null, 
       "search": null, 
       "query": null, 
       "pathname": "/2.0/folders", 
       "path": "/2.0/folders", 
       "href": "https://api.box.com/2.0/folders" 
      }, 
      "method": "POST", 
      "headers": { 
       "User-Agent": "Box Node.js SDK v1.0.0", 
       "Authorization": "[REMOVED BY SDK]", 
       "accept": "application/json", 
       "content-type": "application/json", 
       "content-length": 75 
      } 
     } 
    }, 
    "statusCode": 500, 
    "maxRetriesExceeded": true 
} 

아무도 말해 줄 수 내가 클라이언트를 만든 후에

const sdk = new BoxSDK({ 
    clientID: process.env.CLIENT_ID, 
    clientSecret: process.env.CLIENT_SECRET, 
    appAuth: { 
     keyID: process.env.PUBLIC_KEY_ID, 
     privateKey: fs.readFileSync(path.resolve(__dirname, process.env.PRIVATE_KEY_PATH)), 
     passphrase: process.env.PRIVATE_KEY_PASSPHRASE, 
    }, 
    }); 


    app.use((req, res, next) => { 
    req.sdk = sdk.getAppAuthClient('user', process.env.BOX_USER_ID); 
    next(); 
    }); 

내가 트리거 요청을 : 우선 클라이언트를 만들 내가 뭘 잘못하고있어 ??

답변

0

따라서 문서와 메소드 서명이 일치하지 않습니다. 패키지에 들어가 코드를 직접 확인해야했습니다. 만들려면 :

req.sdk.folders.create(<parent_id>, <folderName>, (e, r) => {...});