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 字段中。