我正在尝试获取会话密钥响应以在 Zapier 会话身份验证中的未来请求中使用,但是从成功身份验证返回的响应是“OK:hbsdakjdkaskjdfvbasdkjh”。我需要提取 hbsdakjdkaskjdfvbasdkjh 然后在下面的 zapier cli 代码中保存为会话密钥变量
我对解析 JSON 有点陌生,但我认为响应实际上是原始的......我尝试了一个正则表达式,但无法找出正确的语句,并想知道是否有人可以帮助我指出正确的方向。
会话 URL 参数等正在工作,并且会话密钥在 OK: 之后响应实际上是正确的,我可以手动将其用于会话的其余部分....
const options = {
url: 'https://theconsole.domain.com.au/api/auth.pl',
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
'accept': 'application/json'
},
params: {
'AccountNo': bundle.authData.AccountNo,
'UserId': bundle.authData.UserId,
'Password': bundle.authData.Password
},
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response.content);
// You can do any parsing you need for results here before returning them
return {
'sessionKey': results.sessionKey
};
});