I want to create Version for ML Engine Model by Rest API and set as default. kindly help me and suggest what is the mistake that I am doing.Sending below request and hitting the post API Below.
Trying hitting by Google Auth Playground.
Post URL : https://ml.googleapis.com/v1/projects//models//versions
Request Body :
{
"name": "v4",
"description": "This is test Version created by API",
"isDefault": True,
"deploymentUri": "gs://car-hertz/vans-uk-hertz/output/v1/F0/export/exporter/1531390162/",
"runtimeVersion": "1.4",
"framework": enum(TENSORFLOW),
"pythonVersion": "2.7"
}
In the REST API docs for the Version resource you can see in the description for the framework field that:
Valid values are TENSORFLOW, SCIKIT_LEARN, and XGBOOST
enum(Framework) is just the field's type. Also, from that same link: isDefault field is output only. You shouldn't include it in the request to create a model version. From the docs for the create method:
If you want a new version to be the default, you must call
projects.models.versions.setDefault.
So, to create a new model version and set it as default via REST API:
Put the request payload in a json file:
{
"name": "v4",
"description": "This is test Version created by API",
"deploymentUri": "gs://car-hertz/vans-uk-hertz/output/v1/F0/export/exporter/1531390162/",
"runtimeVersion": "1.4",
"framework": "TENSORFLOW",
"pythonVersion": "2.7"
}
Create the version by running in a shell the following (I like to use a gcurl alias):
alias gcurl='curl -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" -H "Content-Type: application/json" '
gcurl -X POST -T "$REQUEST_FILEPATH" https://ml.googleapis.com/v1/projects/$PROJECT/models/$MODEL/versions
Set the above as the default:
gcurl -X POST https://ml.googleapis.com/v1/projects/$PROJECT/models/$MODEL/versions/v4:setDefault
Related
I am trying to send a message to myself containing a PDF file stored in Onedrive through Whatsapp API but I am getting the following jpg format:
Message in Whatsapp APP
Oddly enough, when I check Whatsapp Web the same message shows correctly:
Message in Whatsapp Web
What am I doing wrong?
I followed the official documentation and uploaded the media with the following values:
values
This returns me the id:
"id": "7054xxxxxxxxxxx"
Finally, I proceed to send the messsage using that same id:
{
"messaging_product": "whatsapp",
"to": "{{Recipient-Phone-Number}}",
"type": "document",
"document": {
"id": "7054xxxxxxxxxxx",
"caption": "Hello, here is today's Daily Report",
"filename": "dailyreport.pdf"
}
}
Also, I tried retrieving the media URL and got the following output:
{
"url": "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=705479771132690&ext=1670800000&hash=ATvvKq-JEv6kn0bW7kq8SXy00yD1BLX_MMbOK-xxxxxx",
"mime_type": "image/jpeg",
"sha256": "067e1ac9488efc068dbb1ee4a35ae30c1dec575a70a4dcd77f6cbdc396615912",
"file_size": 1912582,
"id": "705479771132690",
"messaging_product": "whatsapp"
}
I guess "mime_type" should be "application_pdf" instead of "image/jpeg". I have no idea why it would say it is an image.
I am pretty new with this so it may be a simple mistake I am not seeing.
Thank you in advanced for your help!
This is a working example to send a pdf:
curl -X POST 'https://graph.facebook.com/v15.0/<MEDIA_ID>/media' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-F 'file=#"documents/sales.pdf"' \
-F 'type="application/pdf"' \
-F 'messaging_product="whatsapp"'
You are supposed to set "type" to the media type you're posting.
See details of supported media types, and limitations, here:
https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types
Try setting the header as content-type not just type:
Content-Type: application/pdf
I have 3 forge viewers that I use, I have no access to buckets from particularly in one viewer. Only difference of this viewer is retention policy: persistent.
When I want to delete or see details an object from a bucket first I get a 2-Legged Token
curl -v 'https://developer.api.autodesk.com/authentication/v1/authenticate'
-X 'POST'
-H 'Content-Type: application/x-www-form-urlencoded'
-d '
client_id=...&
client_secret=...&
grant_type=client_credentials&
scope=bucket:create%20bucket:read%20bucket:delete%20data:write%20data:read%20account:read%20viewables:read'
and then use this token in
curl -v "https://developer.api.autodesk.com/oss/v2/buckets/apptestbucket/objects?limit=1"
-X GET
-H "Authorization: Bearer ..."
-H "Content-Type: application/json"
but when this last call is made, I only recieve
* Connection #0 to host developer.api.autodesk.com left intact
{"reason":"No access"}
Can it be because of retention policy or do I miss something ? Thank you.
Rention policy will not affect your access/permission to a bucket and there're pretty much only two things that would which are whether your Forge app is granted access (owner or authorized via bucket permissions) and the scope of your token.
To view, update or delete a bucket object make sure your token is given the scopes below:
GET bucket(s)/details - bucket:read
GET object(s) - data:read
DELETE object - data:write
PUT object data:write
And to determine whether your current client credentials have access to a bucket use GET buckets to list all your buckets:
{
"items" : [ {
"bucketKey" : "00001fbf-8505-49ab-8a42-44c6a96adbd0",
"createdDate" : 1441329298362,
"policyKey" : "transient"
}, {
"bucketKey" : "0003114d",
"createdDate" : 1440119769765,
"policyKey" : "transient"
}, {
"bucketKey" : "0003fbc1-389a-4194-915a-38313797d753",
"createdDate" : 1453886285506,
"policyKey" : "transient"
}, {
...
When making a request to the MapBox API to create a new dataset we keep getting a response 404 {
"name": "foo",
"description": "bar"
}.
We are sending the code:
curl -X POST “https://api.mapbox.com/datasets/v1/username?access_token=TOKEN” \
-d #mapboxtest.json \
--header “Content-Type:application/json
Problem Solved!!!
It's just a wierd message. My token key is not allowed to change datasets, that was the problem. It was the default public key!
I have a sample code here. It is json
{
"document":{
"type":"PLAIN_TEXT",
"content":"Joanne Rowling, who writes under the pen names J. K. Rowling and Robert Galbraith, is a British novelist and screenwriter who wrote the Harry Pott$
},
"encodingType":"UTF8"
}
I found a tutorial on google's documentation on Natural Language processing on reading from Google Cloud Storage.
curl -X POST \ -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \ --data "{
'document':{
'type':'PLAIN_TEXT',
'gcsContentUri':'gs://reubucket/textData'
}
}" "https://language.googleapis.com/v1/documents:analyzeEntitySentiment"
And the error that I got is
ERROR: (gcloud.auth) Invalid choice: '*************-_m6csS1Wzlj1pyC_J7vzC0'.
Usage: gcloud auth [optional flags] <group | command>
group may be application-default
command may be activate-service-account | configure-docker | list |
login | revoke
How do I call the command with my API key.
I need a way to change the "content" to entries into my CSV file.
Thank you.
Here is an example of the error that I am receiving please help:
mufaroshumba#reucybertextmining:~/myFolder$ gcloud auth activate-service-account --key-file="/home/mufaroshumba/myFolder/reucybertextmining-74fa66372251.json"
Activated service account credentials for: [starting-*******[CENSORED]#reucybertextmining.iam.gserviceaccount.com]
mufaroshumba#reucybertextmining:~/myFolder$ curl "https://language.googleapis.com/v1/documents:analyzeSentiment?key=${API_KEY}" \ -s -X POST -H "Content-Type: app
lication/json" --data-binary #request.json
{
"error": {
"code": 401,
"message": "Permission to access the GCS address is denied.",
"status": "UNAUTHENTICATED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document.gcs_content_uri",
"description": "Permission to access the GCS address is denied."
}
]
}
]
}
}
curl: (6) Could not resolve host: -s
mufaroshumba#reucybertextmining:~/myFolder$
I then used this website trying to get
It looks like your auth is not setup correctly. If you just run this command:
gcloud auth application-default print-access-token
it should be giving you a token, but it seems like it's not. Please follow the steps here to make sure that this command is working first:
https://cloud.google.com/natural-language/docs/quickstart#quickstart-analyze-entities-cli
Then, as long as you have permission to access the gcs bucket, you should be able to get content out of it. Note that the API is expecting to see the actual content in the gcs file, and not a CSV.
BrowserStack now offers a ScreenShot API which allows you to post a request and receive back HTML/JSON with a link to generated screen shot images stored on their server:
http://www.browserstack.com/screenshots/api
The examples are sparse, and use CURL to do all the transport.
1) What is the quick and dirty way to automate w/curl and dump these screens into a folder
2) How would one consume this request architectural in a .NET console/web app to automate this process?
This seems so new there is no documentation or examples on its usage anywhere.
An example request:
curl -u "username:password" -H "Accept: application/json" -d 'data={"browsers": [{"os": "Windows", "os_version": "7", "browser_version": "8.0", "browser": "ie"}], "url": "http://google.com"}' http://www.browserstack.com/screenshots
And the response:
Response {
"job_id":"13b93a14db22872fcb5fd1c86b730a51197db319",
"callback_url": "http://staging.example.com",
"win_res": "1024x768",
"mac_res": "1920x1080",
"quality": "compressed",
"screenshots": [{
"os":"Windows",
"os_version":"XP",
"browser":"ie",
"id":"be9989892cbba9b9edc2c95f403050aa4996ac6a",
"state":"pending",
"browser_version":"7.0",
"url":"www.google.com"
},
{
"os":"Windows",
"os_version":"7",
"browser":"ie",
"id":"1f3a6054e09592e239e9ea79c247b077e68d3d71",
"state":"pending",
"browser_version":"8.0",
"url":"www.google.com"
}
....
]
}
Get status of screenshots in queue
Usage GET /screenshots/<JOB-ID>.json
etc.
The answer to this is to use CURL and read the CURL help files and find a good GUI tool (duh).