Webhook event not received from Autodesk Forge API - autodesk-forge

I'm using the Autodesk Forge API to convert a range of models from various formats into SVF files, and trying to use the Webhooks API to listen for transformation complete events for jobs posted to the Model Derivative service.
I have successfully created the webhook, and verified its existence by calling the get Hooks API endpoint. Below is the basic response i receive.
{
"hookId": "<my-hook-id>",
"tenant": "<my tennant>",
"callbackUrl": "<ngrok url>",
"createdBy": "...",
"event": "extraction.finished",
"createdDate": "2020-11-05T05:48:39.016+0000",
"system": "derivative",
"creatorType": "Application",
"status": "active",
"scope": {
"workflow": "<my-workflow-key>"
},
"urn": "<webhook-urn>",
"__self__": "..."
}
At my ngrok endpoint I have a basic Node ExpressJS server running. The server is set to respond to all methods across my designated callback url. I have also verfied my callback url is valid and active through postman, with POST request being successfully received and returning a valid 2XX reponse.
I then post a translation job like below to the Model Derivative API, and the job successfully starts and processes the job. I can verify this by manually calling to check the status of a job through the Model Derivative API, however my webhook callback endpoint never receives any notification of transformation completion event.
{
"input": {
"urn": "<Input Urn>"
},
"output": {
"destination": {
"region": "us"
},
"formats": [
{
"type": "svf",
"views": ["3d"]
}
],
"misc": {
"wokflow": "<my-workflow-key>"
}
}
}
Is there anything obvious that I might be missing as to why the webhook event never seems to be triggered, or any other way that I could see if the webhook event was even attempted to be fired from Autodesks/Forges side?

There seems to be a typo in the job payload: wokflow should be workflow.
Note that you can also test incoming webhook requests using online tools such as https://webhook.site.

Related

How to Ingest data into AWS Kinesis from Particle cloud JSON web hook

Does anyone have experience or any idea to send a JSON payload to ingest data into AWS Kinesis?
I use Ubidots right now to visualize data but now I want to use AWS QuickSights for analyzing and visualizing it.
This is how a web hook looks :
{
"Alerts": "{{Alerts}}",
"Resets": "{{Resets}}",
"Battery": "{{Battery}}",
"Distance": "{{Distance}}",
"Temperature": "{{Temperature}}"
}
I want an API endpoint through which I can send the data to the cloud.
Is it necessary to send the data to AWS IoT Core and then send it to kinesis from there or I can directly send it from Webhook to Kinesis. Once I have data in the Kinesis, I can load it into the QuickSights dashboard.
Thanks,
Hannan
Here's an example leveraging API Gateway. The API Gateway endpoint triggers a Lambda function that sends the payload to DynamoDB, but this could easily be a Kinesis Stream. If you would like to bypass the Lambda function, you can also configure API Gateway as a proxy for Kinesis directly.
{
"event": "sendSleep",
"url": "https://[yourendpoint].execute-api.us-east-1.amazonaws.com/prod/ParticleSleepV1",
"requestType": "Post",
"headers": {
"x-api-key" : "[yourapikey]"
},
"json": {
"name": "{{SPARK_EVENT_NAME}}",
"data": "{{SPARK_EVENT_VALUE}}",
"source": "{{SPARK_CORE_ID}}",
"published_at": "{{SPARK_PUBLISHED_AT}}"
},
"mydevices": true,
"noDefaults": true
}

Microsoft Custom Vision API: 404, Resource not found

I am trying to use Microsoft's Custom Vision API, but am running into nothing but 404 errors. How can I use the API?
I have tried copying and pasting and modifying the prediction sections of the Python and Javascript samples, such as the one found here: https://github.com/Azure-Samples/cognitive-services-node-sdk-samples/blob/master/Samples/customvision/customVisionImgClassify.js
Copying and pasting the prediction URL into my browser from the Perfomance page of Custom Vision, which is:
https://japaneast.api.cognitive.microsoft.com/customvision/v3.0/Prediction/999999999999999/classify/iterations/Iteration4/image
, yields the same 404 error:
{ "error":{ "statusCode": 404, "message": "Resource not found" }}
The closest I have gotten to successfully accessing the API is through an Azure Logic App, which uses an old version of Custom Vision:
/customvision/v1.0/Prediction/99999999999999999/image
This access method yields an "Unauthorized" error instead of a 404.
I tried modifying the JSON in the Azure Logic App to use the newer version of Custom Vision but am back to getting 404 errors. See below for the JSON (I replaced the keys and IDs with 9s):
"Predict_tags_from_image": {
"inputs": {
"body": "#triggerBody()",
"headers": {
"Content-Type": "application/octet-stream",
"Prediction-Key": "9999999999999"
},
"host": {
"connection": {
"name": "#parameters('$connections')['cognitiveservicescustomvision_1']['connectionId']"
}
},
"method": "post",
"path": "https://japaneast.api.cognitive.microsoft.com/customvision/v3.0/Prediction/9999999999999/classify/iterations/Iteration4/image"
},
"runAfter": {
"Create_file": [
"Succeeded"
]
},
"type": "ApiConnection"
}
Thank you in advance for any help with this!
I tried creating a request with the url you provided and couldn't reproduce the 404 issue. It's showing 401, as I do not have your project id or prediction key. But when I try with my own project and prediction key, everything works and it's returning 200 OK.
Could you please confirm the prediction url and prediction key header and try again?

Graph API: Check if feed post was made by a Page or User

When using the /page/feed endpoint in the Facebook Graph API I can't figure out how to know if the post was made by a Page or a User
Here's how I call the endpoint right now:
HTTP GET https://graph.facebook.com/v2.8/{page_id}/feed?fields=is_published,from,message
This yields the following JSON response:
{
"data": [
{
"from": {
"name": "Chad Smith", # <-- This is a User
"id": "806273209398023"
},
"message": "A really magical place! Best Christmas...",
"id": "103988597020_1445496708809010"
},
{
"from": {
"name": "Tivoli", # <-- This is a Page
"id": "103988597020"
},
"message": "Hello everybody...",
"id": "103988597020_10154040865527021"
},
]
}
How can I know if the post was from a Page or User without making additional API calls? I've tried using subfields, but can't figure out if they work on the from field.
I solved it by using ?fields=from{name,about} and marking it as a Page if the from JSON contains about.
This is not the best solution, but about is currently the only subfield of from that doesn't fail on User. (e.g. if I was using ?fields=from{fan_count} the Graph API will fail for posts made by User objects.

How to get customAPI url from node.js app?

I am just starting with BlueMix and in my space I have:
a Cloud Integration service: using a Basic Secure Connection, for which I have created an API endpoint; then in that Cloud Integration service I have added the corresponding API by importing a swagger 1.2 file, and published that customAPI to my organization;
a pretty simple node.js application;
From the Cloud Integration service> API view, I can get the URLs for the different resources (for instance http://endpoint_ip:endpoint_port/api/version/path_to_resource), so I can hardcode these URLs in my node.js application and it works.
But if I bind the Cloud Integration service and even the customAPI to my node.js application, I don't get any information in VCAP_SERVICES about the endpoint URL; but I have seen examples of VCAP_SERVICES where the API URL is available.
Below is my VCAP_SERVICES
{"CloudIntegration": [
{
"name": "Cloud Integration-b9",
"label": "CloudIntegration",
"plan": "cloudintegrationplan",
"credentials": {
"userid": "apiuser#CloudIntegration",
"password": "S!2w3e40",
"apis": [
{
"name": "Catalog Manager API",
"desc": "Catalog Manager API",
"resource": ""
}
]
}
}
]
}
What I am trying to achieve is to avoid hardcoding URLs in my application, since I can bind a BlueMix service to it, and perhaps get info from the environment.
Am I doing something wrong? Or is that not the way it is supposed to work?
Also I don't really get why there is nothing in the VCAP_SERVICES.CloudIntegration[0].credentials.apis[0].resource even though I have my customAPI specifies resources.
#Rick
Make sure you "publish" your API after configuring the Cloud Integration service. Then service credentials will reflect the changes:
"CloudIntegration": [
{
"name": "Cloud Integration-v5",
"label": "CloudIntegration",
"plan": "cloudintegrationplan",
"credentials": {
"userid": "apiuser#CloudIntegration",
"password": "S!2w3e40",
"apis": [
{
"name": "SwaggerPetStore",
"desc": "SwaggerPetStore",
"resource": "http",
"baseurl": "http://mypypatchank.mybluemix.net"
}
]
}
}
]
in the same way, if you use the API management service, you will have a corresponding VCAP_SERVICES entry
"Swagger Petstore v1 : Sandbox 551b2dcf0cf2521d98d061d4 prod": [
{
"name": "Swagger Petstore v1 : Sandbox prod-w0",
"label": "Swagger Petstore v1 : Sandbox 551b2dcf0cf2521d98d061d4 prod",
"plan": "plan1 : Sandbox prod",
"credentials": {
"clientID": "55cfe3fa-ff59-474c-a1b6-46d3cc9871",
"clientSecret": "uK3xM3eF4cA1qF7yW8mC2lP6wS6aG7sQ5cL2yJ4sC6iS1dE7",
"url": "https://api.eu.apim.ibmcloud.com/garciatemx1ibmcom/sb/api"
}
}
]
Since your goal is to "to avoid hardcoding URLs in my application, since I can bind a BlueMix service to it, and perhaps get info from the environment." I would like to suggest using a user provided service.
This will create a user provided service and start interactive input for you to enter the api url and a password. You can add more parameters if you need.
cf cups servicename -p "url, password"
Bind this service to your application and restage. You can access these parameters in your Node.js application easily with the cfenv module.
var cfenv = require("cfenv");
var appEnv = cfenv.getAppEnv();
var myService = appEnv.getService("servicename");
//use myService.credentials.url to access the url value.
//use myService.credentials.password to access the password value.
The user provided services VCAP_SERVICES looks like:
{
"user-provided": [
{
"name": "servicename",
"label": "user-provided",
"credentials": {
"url": "myURL",
"password": "myPassword"
}
}
]
}

Sencha touch get json error

Every time i try to work with sencha touch to get a json feed i always get this error.
XMLHttpRequest cannot load http://api.example.com/index.php/news/all/format/json?_dc=1342630239638&node=root. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.
how can i fix a work around to stop this i really want to work with sencha but most of my work will be working with json feeds???
any help
also my json outputted looks like this it doesnt have a rootproperty node??
[{
"id": "7253",
"title": "hello",
"description": "",
"source": "syrianews",
"cat_name": "Syrianews"
}, {
"id": "7208",
"title": "hello",
"description": "",
"source": "syrianews",
"cat_name": "Syrianews"
}]
It appears you are trying to do a cross domain Ajax request, which is not allowed. Ajax requests have a security requirement of same domain, same port, same protocol. If you load your app from say http://www.tinyfactory.co/ and then try to make an Ajax request to http://api.example.com/ the security sandbox will not allow it.
But there is hope. Enter JSONP. JSONP or padded JSON (http://en.wikipedia.org/wiki/JSONP) is a way to bypass this security policy if the domain you are requesting the data from plays nice. Typically you will see a param on the API named "callback" What this does is wrap the data in a Javascript function you declare. for example:
http://api.example.com/datafeed.json?callback=foo
would return the data
foo({fName: 'Alex', lName: 'Rolek'});
JSONP is able to achieve this by dynamically inserting a script tag into the DOM with the 'src' attribute set to the API you are requesting with the callback request var. When the API returns the response the function 'foo' is called in your application and you can start working with the response data.
In Sencha Touch, change:
proxy: 'ajax'
to
proxy: 'jsonp'
On your request. As long as the API accepts callbacks, Sencha Touch will do the rest of the heavy lifting.
For additional information, check out:
http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.JsonP
Hope this helps.
Can Sencha read such non-root response?
[{
"id": "7253",
"title": "hello",
"description": "",
"source": "syrianews",
"cat_name": "Syrianews"
}, {
"id": "7208",
"title": "hello",
"description": "",
"source": "syrianews",
"cat_name": "Syrianews"
}]