如何将私有成员添加到外部api

如何将私有成员添加到外部api,api,base64,external,velo,Api,Base64,External,Velo,大家下午好 我正在尝试创建一个功能,该功能将通过我的外部忠诚度计划(通过Whisqr)为我的Wix.com网站上的当前用户自动创建会员资格。我收到一条错误消息,说明找不到公钥 以下是我的后端代码: import {fetch} from 'wix-fetch'; import {wixData} from 'wix-data'; export function postLoyalty() { let options ={ "headers": { "X-Publi

大家下午好

我正在尝试创建一个功能,该功能将通过我的外部忠诚度计划(通过Whisqr)为我的Wix.com网站上的当前用户自动创建会员资格。我收到一条错误消息,说明找不到公钥

以下是我的后端代码:

 import {fetch} from 'wix-fetch';  
import {wixData} from 'wix-data';


export function postLoyalty() {
 let options ={
 "headers": {        
 "X-Public": "pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76"
        }
  }
 const url = 'https://whisqr.com/api/v1.2/user/customer/';
 const key = '<pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76>';
     console.log("Url: ");

 return fetch(url, {method: 'post'})
    .then(response => {
 return response.json();
    })
    .then((data) => {
      console.log(data);
 return data;
    });
}


非常感谢您的任何反馈

您正在使用POST方法调用URL,但没有使用您定义的任何键和标题

在请求中使用标题和正文的正确POST调用如下所示:

    export function myFunction(data) {

     const url = "https://whisqr.com/api/v1.2/user/customer/";

      const headers = {
          "Authorization": "Bearer " + key, //if api key is required like this
          "Content-Type": "application/json" //the content type
        };

      return fetch(url, {
            "method": "POST",
            "headers": headers,
            "body": JSON.stringify(data) //if there is a body
        });
    }

您说过您需要在外部平台上创建一个成员,因此您必须发送一个包含客户数据的实体。阅读API文档。

非常感谢您的帮助。我仍然得到一个关于内容的错误没有被发现。我不知道如何编码,我的印象是内容哈希是每个用户生成的。你能进一步解释吗?我的API调用使用HMAC SHA256生成的内容哈希,但我不确定如何生成。你能为此提供帮助或提供任何文章/教程吗?我仔细阅读了这篇文章,无法确定“秘密密钥”和“秘密消息”是什么。
    export function myFunction(data) {

     const url = "https://whisqr.com/api/v1.2/user/customer/";

      const headers = {
          "Authorization": "Bearer " + key, //if api key is required like this
          "Content-Type": "application/json" //the content type
        };

      return fetch(url, {
            "method": "POST",
            "headers": headers,
            "body": JSON.stringify(data) //if there is a body
        });
    }