I have defined Reshooks for subscribe and unbsubscribe. The subscribe endpoint returns the targeturl as a response. I use this url in postman which returns me the subscription id. I then pause My Zap which calls my Unsubscribe Endpoint but the Id is coming as null. Any idea what is wrong here?
Below is my code for Susbcribe Resthook
const options = {
url: 'baseurl/api/subscription/subscribe',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-API-KEY': bundle.authData.API_Key
},
params: {
'API_Key': bundle.authData.API_Key,
'url': bundle.targetUrl
},
body: {
'hookUrl': bundle.targetUrl
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
// You can do any parsing you need for results here before returning them
return results;
});
Below is the subscribe api endpoint. I receive the value in the url parameter successfully when I turn on my Zap.
uHttpPost]
public async Task<string> Subscribe(string url)
{
DocumentDBRepository<SubscriptionModel>.Initialize();
await DocumentDBRepository<SubscriptionModel>.CreateItemAsync(new SubscriptionModel() { type = "Subscribe", response = url});
return "success";
}
I then trigger the zappier hook url using Postman and I get following response.
{
"id": "9476aacc-d162-4ed3-8616-db4353657e2e",
"request_id": "603d52b6-26ac-4b8e-871f-b0ed9d4d1a90",
"attempt": "603d52b6-26ac-4b8e-871f-b0ed9d4d1a90",
"status": "success"
}
I then pause my Zap which calls the Unsubscribe endpoint but the Id comes null.
Below is the Code for Unsubscribe Resthook
const options = {
url: 'https://claritywebapi101.azurewebsites.net/api/UnSubscription/UnSubscribe',
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
params: {
'id': bundle.subscribeData.id
},
body: {
'hookUrl': bundle.subscribeData.id
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
// You can do any parsing you need for results here before returning them
return results;
});
Here is my Unsubscribe api endpoint. Here the id parameter is coming as null when I pause my Zap. Why?
sHttpDelete]
public async Task<string> UnSubscribe(string id)
{
await DocumentDBRepository<SubscriptionModel>.CreateItemAsync(new SubscriptionModel() { type = "Unsubscribe", response = id });
return "Unsubscribed successfully" + id;
}