{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/zh-TW/develop/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"偵錯指南","description":"YouCam API documentation by Perfect Corp. Learn how to use Skin analysis API, Virtual try-on API, Image editing API, and Video generative AI APIs.","siteUrl":"https://docs.perfectcorp.com","keywords":"AI Skin Analysis, AI Clothes, AI Hairstyle, AI Outfits","image":"/assets/favicon.cd6fa4d833b2a573b3c6dae68386b293da205b203402cb0c97b80bd2acc07ea2.8351e24f.png"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"偵錯指南","__idx":0},"children":["偵錯指南"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Invalid TaskId 錯誤"]}," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["原因："]}," 若任務超過保留期限，之後任何狀態查詢都會回傳 InvalidTaskId 錯誤。為避免此情況，請在啟動 AI 任務後設定 webhook 或實作輪詢，並在保留期限內持續監控其狀態，直到抵達 success 或 error 的最終狀態。"," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["解法："]}," 為避免任務過期，請實作輪詢迴圈，在保留期限內以固定間隔檢查任務狀態。"," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["使用 AI API 時出現 404 Not Found 錯誤"]}," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["答："]}," ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["重要"]}]},"：僅呼叫 File API 並不會上傳您的檔案。您必須手動將檔案上傳到 File API 回應中提供的網址。該網址就是您的上傳目的地，請確認檔案已成功傳送到該處後再繼續。",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}," ","在呼叫 AI API 之前，請確認檔案已成功上傳。使用 File API 取得上傳網址，然後將檔案上傳至該位置。上傳完成後，回應中會收到一個 ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["file_id"]}]},"，這個 ID 就是您存取該檔案相關 AI 功能時要使用的識別碼。"," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API 回應在 Postman 上回傳相同的 style ID"]}," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["答："]}," 這是因為 Postman（Pretty view）與 Chrome 使用 JavaScript 解析 JSON 回應。在 JavaScript 中，大於 9007199254740991（2^53-1）的數字無法被精確表示。它們會被四捨五入到最接近的可表示值，使得不同的 ID 看起來完全相同（例如 219691778809271815 → 219691778809271800）。",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["JavaScript/JSON 中的精度遺失與錯誤處理",{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["原因：JavaScript 的 Number 型別無法安全處理超過 2^53 - 1 的整數，會造成無聲的截斷或四捨五入。"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["解法：使用如 ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["json-bigint"]}]}," 的 JSON 解析器，將 ID 視為字串以保留完整精度。"," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}]}]}]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Beard 認證 400 錯誤"]}," ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["答："]}," 使用 V2 API 時，您必須在每個請求中加入 API 金鑰，也就是加上 Bearer 授權標頭。未如此做將會造成認證錯誤。"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["正確的請求標頭格式"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Authorization: Bearer YOUR_API_KEY\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["常見問題"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["缺少 Bearer 前綴"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," 標頭必須以 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Bearer"]}," 開頭，後接 API 金鑰。"," ","範例："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Authorization: YOUR_API_KEY\n"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["多餘的字元"]}," ","不要在 API 金鑰兩側加上尖括號 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<"]}," 或 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[">"]},"。這些字元是不需要的，會造成請求失敗。"," ","範例："]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Authorization: Bearer <YOUR_API_KEY>\n"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API 金鑰不正確"]}," ","請確認 ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," 標頭中提供的 API 金鑰正確且有效。"]}]}]}]}]}]},"headings":[{"value":"偵錯指南","id":"偵錯指南","depth":1}],"frontmatter":{"seo":{"title":"偵錯指南"}},"lastModified":"2026-10-30T07:26:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/zh-tw/develop/debugging_guide","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}