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?
Related
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.
I have an existing client-id (Web) with some working UIDs, I added a time ago. I now wanted to add one more and when I press the save button it just does not work (ProgressIndicator is spinning infinitely). I have a working internet connection and tried with several browsers (Safari,Chrome).
Has anyone seen this?
Edit:
I just tried again with it. I got this error in the web console:
{
"error": {
"code": 400,
"message": "The request failed because one of the field of the resource is invalid.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.PreconditionFailure",
"violations": [
{
"type": "client_auth_config",
"subject": "?error_code=9&error_field_name=pending_domains&error_field_value=test-page.web.app"
}
]
}
]
}
}
When I added a domain that ended in .firebaseapp.com, everything worked. Since the domain I want to use ends in .web.app, I have a problem with this though.
I am trying to move files on our internal TFS using Python and the TFS REST API; the server appears to only support the API up-to version 2, but on MSDN I cannot find any docs for versions below v4.1.
The URL I'm posting to is https://<server>/tfs/<Collection>/<Project>/_apis/tfvc/changesets
Currently my best guess at the correct JSON body for the post request looks like this:
{
"comment": "moved file",
"changes": [{
"changeType": "rename",
"item": {
"path": "<filepath>",
"version": 468,
"sourceServerItem": "<filepath>"
}
}]
}
But i cannot get further than an HTTp error 400 bad request with the following message
{
"$id": "1",
"innerException": null,
"message": "Exactly one value for PathActions is required.\r\nParameter name: change.SourceServerItem",
"typeName": "System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}
And for the life of me i cannot find any reference to PathActions on google, that is not for git instead of tfvc, or a correct way of providing a value for this item.
Does anybody have a way of renaming/moving files on a TFVC via a HTTP request?
It just occurred to me to do a rename using the TFS web interface and peek at the request sent by the browser.
Turns out this is the correct format:
{
"comment": "Moved File",
"changes": [
{
"changeType": 8,
"sourceServerItem": "<old path>",
"item": {
"path": "<new path>",
"version": 470
}
}
]
}
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.
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"
}]