Question
Michael Fimbres · Jun 18, 2020

Getting error when using getJSON method in %Net.Http

Running Cache 2017.2.2.

I'm trying to make a REST API call in JSON format. When using the example in the class reference documentation the getJSON method in the %Net.Http class throws the error  <METHOD DOES NOT EXIST> on a %Clone() method in the %LIbrary.DynamicObject class. I even changed the parameter to a JSON string to no avail. The  code will then fail on the %Compose method (examples below). My workaround is to use the %Net.HttpRequest functionality. Is there another workaround to this?

 

Example As Is:

USER>set continents = ##class(%Net.Http).getJSON("http://localhost:57772/api/document/v1/SAMPLES/continents",{"Username":"_SYSTEM","Password":"SYS"}

<METHOD DOES NOT EXIST>zgetJSON+12^%Net.Http.1 *%Clone,%Library.DynamicObject
USER>

Example with a JSON string:

USER>set continents = ##class(%Net.Http).getJSON("http://localhost:57772/api/document/v1/SAMPLES/continents",{"Username":"_SYSTEM","Password":"SYS"}.%ToJSON())

<METHOD DOES NOT EXIST>zgetJSON+43^%Net.Http.1 *%Compose,%Library.DynamicObject
USER>

 

00
1 0 2 118
Log in or sign up to continue

Replies

The example  and the class are simply wrong 
%Library.DynamicObject that is composed here just has neither a method  %Clone nor a method %Compose

You may report the bug to WRC

%Net.HttpRequest is a correct way to go about it.