I'm guessing you want to write an app that can receive http calls. Here's an example you can use. It may not work as I stripped out a lot of code but the key points is looking at the mappings section as that routes it to the handler. You also need to enable oauth when you add the app.
It should give a you a good idea as to how you can receive a call and action on it.
definition (
name: "Sample Endpoint App",
namespace: "GvnCampbell",
author: "Gavin Campbell",
description: "",
iconUrl: "",
iconX2Url: "",
singleInstance: true
)
preferences { page(name: "pageConfig") }
def pageConfig() {
dynamicPage(name: "", title: "", install: true, uninstall: true, refreshInterval:0) {
section ("Devices",hideable:true,hidden:true) {
input(name:"requestSource",type:"enum",title:"Allow Requests From",options:[0:"Cloud and Local",1:"Cloud Only",2:"Local Only"],defaultValue:0,required:true)
}
if (!state.accessToken) {
createAccessToken() // create our own OAUTH access token to use in webhook url
}
section("URL's",hideable:true,hidden:true) {
paragraph("<b>Running a command locally:</b>\n" +
"${getLocalApiServerUrl()}/${app.id}/device/command/[Device ID]/[Command]?access_token=${state.accessToken}\n" +
"<b>Setting an attribute locally:</b>\n" +
"${getLocalApiServerUrl()}/${app.id}/device/attribute/[Device ID]/[Attribute]/[Value]?access_token=${state.accessToken}")
paragraph("<b>Running a command remotely:</b>\n" +
"${getApiServerUrl()}/${hubUID}/apps/${app.id}/device/command/[Device ID]/[Command]?access_token=${state.accessToken}\n" +
"<b>Setting an attribute remotely:</b>\n" +
"${getApiServerUrl()}/${hubUID}/apps/${app.id}/device/attribute/[Device ID]/[Attribute]/[Value]?access_token=${state.accessToken}")
}
}
}
// *** [ Initialization Methods ] *********************************************
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
}
// *** [ Webhook Methods ] ****************************************************
mappings {
path("/device/command/:d/:c") {
action: [
GET: "handlerWebhook"
]
}
path("/device/attribute/:d/:a/:v") {
action: [
GET: "handlerWebhook"
]
}
}
def handlerWebhook() {
log.debug "request: ${request}"
log.debug "params: ${params}"
if (requestSource=="0" || (requestSource=="1" && request?.requestSource=="cloud") || (requestSource=="2" && request?.requestSource=="local")) {
} else {
log.debug "Requests from '${request?.requestSource}' are blocked."
}
}