8

Yes, it's possible to do that. Here is a toy code. CloudDeploy[ APIFunction[{}, Function[{}, Table[10 i + j, {i, 10}, {j, 4}]], "CSV"] , "csv-test-data", Permissions -> "Public" ] CloudObject["https://www.wolframcloud.com/obj/your-user/csv-test-data"] Then just go to you sheet and use the IMPORTDATA function ...


8

Ultimately the body can be extracted by using HTTPRequestData HTTPRequestData[] will return an Association containing properties and values. Usually you can specify the specific property you want, like "Body" (I seem to remember some issues getting "MultipartElements" at some point in time). obj = CloudDeploy[APIFunction[{}, HTTPRequestData["Body"] &]]...


7

This should work: First use a named CloudObject (that way you don't have to constantly update your web page every time you make changes to your APIFunction and redeploy it): CloudDeploy[ APIFunction[{"myfile"->"CSV"}, Dimensions[#myfile]& ], CloudObject["filetest"], Permissions -> "Public" ] Note, I simplified the APIFunction code to ...


6

Currently APIFunction / CloudDeploy works only with the Public Cloud or an Enterprise Private Cloud. So either you need an EPC on your side or you can use WebMathematica or Mathematica (WebMMA license required anyway). Though WebMMA does not support APIFunctions anyway so you'd have to adapt it to create JSP based api interface. Let's hope someone in WRI ...


5

I think this part of the interface is broken. From some digging I found: ZeroMQLink`SocketOptions`Private`setSockOptSingle which is called by SetOptions on a SocketObject. This makes use of ZeroMQLink`SocketOptions`$SetSocketOptionTypes to check the type of the argument and ZeroMQLink`SocketOptions`$SetSocketOptionValues to get the integer for what I'm ...


4

You can do something like this (encoding the PNG in Base64): randomClock[t_] := Rasterize[ Graphics[ Rotate[ClockGauge[t][[1]], RandomReal[{0, 2 \[Pi]}], {0, 0}], ImagePadding -> 0], ImageSize -> 300]; randomClockDeploy[] := With[{t = RandomChoice /@ Range /@ {12, 60, 60}}, <| "img" -> ExportString[randomClock[t], {"Base64", ...


3

Sorry for the late response. There is indeed a problem with ZMQ option management. @b3m2a1 did a very good job at digging into the code for an answer. The expected input is a list of integer (list of bytes to be more specific), but it's not WXF (this code predates WXF). It's actually the string bytes : The following subscriber will only read messages ...


3

https://www.wolfram.com/language/12/networking-and-system-operations/zeromq-publisher-model.html pub = SocketOpen[Automatic, "ZMQ_PUB"] subscribers = Table[SocketConnect[pub["DestinationPort"], "ZMQ_SUB"], 3] Scan[SetOptions[#, "ZMQ_SUBSCRIBE" -> All] &, subscribers] WriteString[pub, "Message from publisher socket."] ByteArrayToString[...


3

Alright, I got into contact with the support for the API, and the problem was resolved on their end. Apparently, it was an error in the routers' networking configuration.


3

So after some digging and breaking "MQTTLink`" for while I found that "MQTTLink`" is passing garbage out to its handler functions. The heart of the problem is what's passed to that "AsyncHandler" you found. MQTT must work via some message / topic framework, as we find this in the source, when configuring the server: MQTTLink`TopicSubscribe[client, "...


3

You may want to implement the PermissionsKey option in the API deployment permissions: obj = CloudDeploy[APIFunction[{"n" -> Integer}, #n^2 &], Permissions -> {PermissionsKey["thekey"] -> "Execute"}] Then you can make a request with _key=thekey in the query string. For a more fine-grained access you may want to implement something like JWT ...


2

As Lukas Lang said, You need to specify "String" as result type for the APIFunction, as in APIFunction[{"y" -> "Number"}, ExportString[...] &, "String"]. Otherwise you will get the input-form like representation of the resulting string. The function now works: CloudDeploy[ APIFunction[{"y" -> "Number"}, ExportString[{"TestData" -> {"...


2

Now there's WolframWebEngine which allows one to create a sort of personal wolfram cloud.


2

I am not sure how many of y'all have been keeping up with the Community discussion, but there are some key updates I wanted to summarize here: ScheduledTask does not store values; it is essentially a block of code that produces a result which it then discards. AutoRefreshed works better wrt deployment of tasks to the Wolfram Cloud because AutoRefreshed ...


2

I will show you a small piece of code you can use as a starting point, it is already nice enough. Just compose withLogger[apiPath] with your APIFunction's function. And initialize the log file. Like this: With[{apiPath = "api/foo"}, CloudPut["#API init " <> DateString[], apiPath <> ".log"]; CloudDeploy[ APIFunction[ {"x" -> "...


2

func = APIFunction[{"t" -> "Real", "y"->"Real"}, #t*#y &]; api = CloudDeploy[func, Permissions -> "Public"] You don't need to access it via browser. There are functions for that: URLExecute[api, {"t" -> 1, "y" -> 5}] 5. But if you insist: URLBuild[First@api, {"t" -> 1, "y" -> 5}] // Echo // SystemOpen >> https://www....


2

Here is an extended comment. This seems to be a task for URLDispatcher but as soon as the url contains a file extension the Cloud responds with 500 internal error. Without file extension: obj = CloudDeploy[ URLDispatcher[{ ("/" ~~ a : DigitCharacter .. ~~ "/" ~~ b : DigitCharacter .. ~~ "/image" ) :> ExportForm[...


1

After a bit of playing around, I think I have a workable solution to share. Firstly, let's create a classifier using the titanic datset. cl = Classify[ ResourceData["Sample Data: Titanic Survival"] -> "SurvivalStatus"] Let's now define an API function. Within the function, we want to define the independent variables that are passed ...


1

I contacted Wolfram support and got the following answer. I have forwarded an issue report to our Cloud development team. We hope this can be resolved in the future versions of Wolfram Cloud. So that is not working in Wolfram 12.2.0.0.


1

content = APIFunction[{"x"->"String"},<|"lampstatus"-> "on", "temp" -> 37.2|>[#x]&]; CloudDeploy[content]


1

WRI tech support advise to use this syntax: func = APIFunction["x" -> RepeatingElement[Interpreter[Restricted["Integer", {1,\[Infinity], 1}]]], #x^3 &]


Only top voted, non community-wiki answers of a minimum length are eligible