This question already has an answer here:

Learning mathematica now. Really curious how such a pure function should be written, i.e., an APIfunction that will return a dataset (TargetDataset) record from the string in a http request matching a column (name).

APIFunction[{"x"->"String"}, TargetDataset[Select[#name === #x &]]&]

Doesn't work, the error message is that #x can be selected from the dataset associations.

Any help is appreciated.


marked as duplicate by m_goldberg, Henrik Schumacher, José Antonio Díaz Navas, Kuba Jan 11 at 23:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ The problem is that #x makes sense only in the very outer function. Not in the one that select uses. To resolve confusion of the slot you can use Function with named arguments, like this: APIFunction[{"x"->"String"}, Function[input, TargetDataset[Select[#name === input["x"] &]]]]. $\endgroup$ – Kuba Jan 11 at 23:17