For me, i was working with Wistia and the payload is like:
{
"hook": {
"uuid": "bb812395-8d23-4285-9278-9ca014209ae7"
},
"events": [{
"uuid": "09e67473ecb3a000",
"type": "viewing_session.percent_watched",
"payload": {
"visitor": {
"id": "v20150227_bee7121c-04bb-42ae-abc9-5327f536df0f"
},
"viewing_session": {
"id": "v20150225_52967e29-8196-42d8-9dc6-952c1d9ec87f"
},
"percent_watched": 25,
"media": {
"url": "http://dave.wistia.com/medias/mmgzi8h6yh",
"thumbnail": {
"url": "http://embed.wistia.com/deliveries/23c4846eecd462beab57a508dff7f052a5faf065.jpg?image_crop_resized=200x120"
},
"name": "Lenny Eating Peanuts",
"id": "mmgzi8h6yh",
"duration": 71.912
}
},
"metadata": {
"account_id": "8lq25o0p9c"
},
"generated_at": "2016-03-30T15:14:01Z"
}]
}
When i was trying to access the element String, sObject type variable it was showing me the defined error. Finally i modified the class and it worked.
global class hookWrapper {
String uuid;
}
global class ThumbnailWrapper {
String url;
}
global class VisitorWrapper {
String id;
}
global class ViewingSessionWrapper {
String id;
}
global class MetadataWrapper {
String account_id;
}
global class MediaWrapper {
String url;
String name;
String id;
Double duration;
ThumbnailWrapper thumbnail;
}
global class payloadWrapper {
Integer percent_watched;
MediaWrapper media;
VisitorWrapper visitor;
ViewingSessionWrapper viewing_session;
}
global class eventWrapper {
String uuid;
String type;
payloadWrapper payload;
MetadataWrapper metadata;
String generated_at;
}
@HttpPost
global static void check(hookWrapper hook, eventWrapper[] events) {
eventWrapper event = events[0];
String type = event.type;
Integer percentWatched = event.payload.percent_watched;
String contentUrl = event.payload.media.url;
String name = event.payload.media.name;
String mediaId = event.payload.media.id;
String accountId = event.metadata.account_id;
String content = 'content : ' + contentUrl + ' name: ' + name + ' type: ' + type + ' media_Id: ' + mediaId + ' account_id: ' + accountId + ' percent watched: ' + percentWatched;
}