Dynamics 365 整合指南
使用我們安全的雲端 API,直接在您的 D365 環境中生成高品質條碼。
身份驗證: OAuth2 Client Credentials
所需權限範圍 (Scope): barcode:generate
1
獲取您的憑據
購買後,您將通過電子郵件收到 Client ID 和 Client Secret。在請求令牌時,請確保包含 barcode:generate 權限範圍。
身份驗證終端點:
POST https://www.barcodesoft.com/api/auth/token
2
配置 Power Automate (推薦)
整合 Dynamics 365 最簡單的方法是通過 Power Automate 流。這使您能夠在整個 Dataverse 實體中實現條碼生成的自動化。
- 觸發器: 當新增或修改資料列時 (Dataverse)。
- 操作: 向
/api/auth/token發送 HTTP 請求以獲取存取令牌。 - 操作: 向
/barcode/v1/qrcode發送 HTTP 請求,並在請求標頭中使用 Bearer 令牌。
3
AL 程式碼實現 (Business Central)
在 Business Central 的擴充功能中,使用以下程式碼片段處理身份驗證和條碼生成:
// 1. 獲取帶有 Scope 的 OAuth 令牌
HttpClient.DefaultRequestHeaders.Add('Accept', 'application/json');
Content.WriteFrom('{"grant_type":"client_credentials","client_id":"您的ID","client_secret":"您的密鑰","scope":"barcode:generate"}');
if HttpClient.Post('https://www.barcodesoft.com/api/auth/token', Content, Response) then begin
Response.Content.ReadAs(ResponseText);
end;
HttpClient.DefaultRequestHeaders.Add('Authorization', StrSubstNo('Bearer %1', AccessToken));
if HttpClient.Get('https://www.barcodesoft.com/barcode/v1/qrcode/?data=Testing&isgs1=false&width=360&height=150&imageformat=svg', Response) then begin
end;
4
顯示條碼
API 返回圖像流 (PNG/JPG/SVG)。在 D365 Sales 中,將回應存儲在圖像欄位中。在 Business Central 中,使用 TempBlob 將資料流式傳輸到 Media 或 Blob 欄位中。