Smartsheet Callback - smartsheet-api-2.0

I have integrated Smartsheet api in PHP, i am able to create the webhook and enable it. When a change is made in the sheet it hits the callback url. I am not receiving any data related to the change. I have logged the data as $_POST which is empty.
function smartWebhook_post(){
log_message('error','SS data: '.print_r($_POST,true), '', 'smartsf');
$this->response(array('HTTP status'=>200));
}
According to the documentation HTTP status 200 has to be sent back.

Every webhook callback will have a JSON body. So I'd look more closely at how you are handing the POST payload.
Note that the very first callback will be a verification request as per http://smartsheet-platform.github.io/api-docs/?javascript#webhook-verification

Related

ironSource Offerwall: check if user has already been rewarded

I'd like to implement an ironSource Offerwall in my app. I manage user's coins with a Firestore document for each user. ironSource documentation says:
check that we haven't processed the same event before
In short, they'll continue to send callback until my server send a 200 code response to their. But how could I implement a function that check for the eventID and check if the event has already been processed? (even though this shouldn't happeb because of the 200 code response, but they suggest to do also this check).

Get a trigger on page visit?

It's so simple yet i can't figure it out.
I would like to write to DB on page visit (without Google Analytics).
I would like to do it on server side.
Since there is no trigger for it, and I redirect all requests to a function, i tried :
exports.contentServer = functions.https.onRequest((request, response) => {
...
...
return response.redirect(url + "?action=" + action )
.then(function(){ // **** error : .then of undefined
//write to DB a visit
Now this will return error since response.redirect will not return a promise. (as Frank said)
I could write to DB before I redirect user, then i make the website slower.
I could do so from client side, which have security problems.
How would I capture and save every page visit ?
In a callable Cloud Function, sending a response to the client is a signal that the request is completely handled, and that Cloud Functions can shut down the contain/use it for other requests.
So there is no way to continue processing after you send the redirect back to the client. You'll either have to perform an additional request from the client, or wait with sending the redirect until you've sent the event to the database.
Note that you won't have to wait for a response from the database, which is how many analytics systems deal with this situation. They send the response, and then trust that the majority if events will make it through.

POST to a webhook?

I created a Discord webhook for my channel, now I am trying to send a POST request to it so my program automatically saves stuff to the channel. However when I send a post request it doesn't work. I added some screenshots for clarification
Bad Request means that your Request is invalid.
Discord only accepts JSON Request Bodies(See https://discordapp.com/developers/docs/resources/webhook#execute-webhook)
As the docs describe, the body should look like that(it is minimalized, see the documentation, replace message with your message):
{
"content": "message"
}
You can also send a file or an embed using this method.
You can also overwrite the default username/avatar of the webhook if you want to.

how do i resend a request after processing it inside my apigee endpoint

I have a endpoint called get user data which accepts a token
I need to read this token in my apigee and send it to tokenVarificationExtUrl
which gets back to me with
a) valid 200
b) userid attached with that token
now what i have to do is i need to read the response header and then conditionally check it for 200 success and then extract the userid from the response.
Once its extracted i need to attach it with another request; which i need to send to getUserData external url
which will get back to me with required user details.
I am successful of extracting data and doing conditional check. I am seeking help for
how do i send another request to getUserData external url.
You need to use a few policies in your proxy.
For example
For checking a header and throwing an error, you may want to use rasie fault policy conditionally
For making an API call to external end-point you can use service callout policy or a standard target
For exrtacting response data from json or xml payload you can use json path of xpath policies
and so on.
I suppose you may want to take a look at a few sample proxies with these functions to be able to design your own.
Check this link out. http://apigee.com/docs/content/using-sample-api-proxies

How can I add custom JSON parameter in JIRA webhook?

I have a web-servise which listens to the JSON requests from different data sources. I want to identify data source by special parameter data-source. My question is how I can add field "data-source": "jira" to the webhook JSON body?
EDIT
For now my solution is to add to my webhook uri http://127.0.0.1:8080/DC data source parameter like this: http://127.0.0.1:8080/DC?data-source=jira, then check data source type and if it is equal to jira send request JSON body to method jiraJsonParser().
But I'm not sure if it is the best solution, isn't it?
I had a similar need, and solved the problem by creating a REST API with flask that acts as an aggregator/translator to accept requests from multiple tools, format the request as needed, and pass it on to it's intended target. For example, I have a Jira 'build request' ticket that sends a POST request via webhook to my API upon ticket creation. The API accepts the request, formats it as needed, fwd's the request on to Jenkins to run a build. As each part of the build runs, Jenkins sends requests back to the API, which get formatted as needed, and the original Jira ticket gets updated with the details/status of the build.
Here's a good article on building a REST API with flask - http://blog.luisrei.com/articles/flaskrest.html

Resources