Message Boards Message Boards

0
|
5866 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Can't figure out how to use this API

Posted 9 years ago

Hi

This may not be strictly a wolfram question but nonetheless, i am looking for some basic help. I used this code to deploy the API -

CloudDeploy[ APIFunction[{"image" -> "Image"}, ImageIdentify[#image]&,"PNG"]]

This works but i can't figure out how to use the API, there is a page that appears asking me to provide the image in query param style, but I am not sure how to do that. See attached screenshotAPI Image upload

How do i provide it an image from my machine?

Thank you for any and all help.

POSTED BY: s a

Hello s a,
If you replace -APIFunction- by -FormFunction- a working userinterface is ready to use. I assume you insist on doing this via a API.

Here is my public API definition with name: picapi.

CloudDeploy[ APIFunction[{"image" -> "Image"}, ImageIdentify[#image] &, "PNG"], "/picapi", Permissions -> "Public"]

To send a picture to this API you need a link to send it to:

http://www.wolframcloud.com/objects/mpg/picapi

note the -mpg- part that replaces the user-UUID part. This is a setting in you wolfram cloud web user interface. Configure your own abbreviation.

Now test the API with the Postman REST Client (getpostman.com)

enter image description here

Send it and this worked for me.

If you want to turn this manual test into code you should implement code like this

POST /objects/mpg/picapi HTTP/1.1
Host: www.wolframcloud.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="1a11447a8b55b94e.png"
Content-Type: image/png


----WebKitFormBoundary7MA4YWxkTrZu0gW

you need a multipart/form-data description. Normally the URLFetch command is able to send this but with pictures it is more difficult. Need to investigate a little further if it can be done.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract