« first day (2932 days earlier)      last day (1549 days later) » 

2:03 PM
Hey all...wondering if someone could help me out with something. I'm trying to do something dead simple but can't quite figure it out and so far, Wolfram Support hasn't been able to help either.

I am trying to create an API and have it respond when I POST some JSON to it. For whatever reason, I can't get the API to "see" the parameters I am passing in the JSON when calling it externally from Postman or Insomnia. Of course when I hit it from the browser and put parameters in the URL it works just fine, so I'm not sure what the deal is...
So, for instance...
api = APIFunction[{"y" -> "Number"}, #y + 3 &, "JSON"];

If I CloudDeploy this API, then try to hit it from Insomnia, Postman, any API tester, I get this:

"Failure": "The API could not be evaluated because there is no input for fields: \"y\"."

The JSON I am sending in the BODY of the request is:

{
"y":15
}
 
2:55 PM
@Aphit Is it documented somewhere that sending JSON in the body of a POST request (if that is what you're doing) should work?
 
@C.E. CloudDeploy docs state "...called externally in the cloud using a web GET request, as from a web browser, or a POST request."
interesting, I'm gonna run a quick test
 
3:08 PM
Hello everybody, how can I "force Mathematica" to cache all the loaded data upon closing the notebook?
Suppose I have a list a={1,2,3}, what box do I tick so that I can declare the variable, save the notebook, close Mathematica, reload Mathematica, reload the notebook, type "a", compile, and find {1,2,3} to be reproduced by the command
 
@kirkus well, even then the standard way of formatting the body is not as a JSON string. More likely the server is expecting a URL encoded body, i.e. y=15
 
@C.E. right, and that seems to work
 
@kirkus ok, good to know. Thank you for finding out.
@Aphit the above is the answer to your question. The body is supposed to be URL encoded, not JSON encoded.
 
3:49 PM
Ah interesting. Okay, will give it a try
 
4:02 PM
That does seem to work. Thank you guys, this has been driving me nuts!
 
great! and if you really need pass in JSON, you could pass it as a string Form parameter and have the API parse it, e.g.:

APIFunction[{"s" -> "JSON"}, Lookup[#s, "y"] + 3 &, "JSON"]

where s is an encoded JSON string

s=%7B+%22y%22+%3A+15+%7D
 
 
2 hours later…
6:18 PM
I have another question:
I keep getting this error
LibraryFunction::nolib: The library <something> cannot be found.
CreateLibrary::fnfnd: File <something>.<extension> not found.
The file is definitely inside the folder
I'm running the new macos, is my operating system blocking access?
When I try to run it on a remote workstation
I get
Import::nffil: File not found during Import.
The only topic I could find mentioned removing weird characters from the file name, but neither file have these weird characters, everything is alphanumeric
It goes without saying both my workstation as well as my local computer have the file present
 
7:03 PM
Something that uses the cloud as a paclet distribution mechanism to do really simple package and stylesheet distribution stuff: mathematica.stackexchange.com/questions/212889/…
 
@b3m2a1 Really nice stuff, I bookmarked that
 
8:35 PM
So even wierder
Somehow my old files are still working, but my new ones are not!
So if I copy a working file off the working station, change one character, save and scp it back, the new file fails to compile
Hopeless
Calling it a day
 
9:09 PM
Okay, so I'm taking my package framework stuff and basically rebuilding a bunch of the parts of BTools in a much more modular, object-oriented fashion. Would it be nice to have it be really easy to make a paclet server? I tried this in the past, but I think I didn't quite get the interface right because it was still a bunch of config work to get everything nice. On the other hand, given that the Paclet Repository is "coming soon" (hopefully) it might not even be worth investing my time...
 

« first day (2932 days earlier)      last day (1549 days later) »