Get code for a revision of a REST API definition

get/restApiDefinitions/{restApiDefinitionId}/revisions/{revisionId}/code

Retrieves the DS2 package code, which can be used to execute the revision of the REST API definition.

Request Samples

Response Samples

1package RestApiDefinition /inline;
2
3 method errorOnRc(integer rc, varchar(1024) msg) returns integer;
4 if rc ne 0 then do;
5 put 'ERROR:' msg ' rc=' rc;
6 end;
7 return rc;
8 end;
9
10 method warnOnRc(integer rc, varchar(1024) msg) returns integer;
11 if rc ne 0 then do;
12 put 'WARNING:' msg ' rc=' rc;
13 end;
14 return rc;
15 end;
16
17
18 method execute(
19 in_out varchar "responseBody" ,
20 in_out double "responseStatusCode"
21 );
22
23 dcl package http serviceCall();
24 dcl varchar(2048) baseUrl;
25 dcl varchar(2048) queryParams;
26 dcl varchar(4097) finalUrl;
27 dcl int rc;
28
29 queryParams = '';
30 responseBody = '';
31 responseStatusCode = -1;
32 baseUrl = 'https://example.com';
33
34 if length(queryParams) > 0 then do;
35 finalUrl = baseUrl || '?' || queryParams;
36 end;
37 else do;
38 finalUrl = baseUrl;
39 end;
40
41 rc = serviceCall.createGetMethod(finalUrl);
42 if 0 ne errorOnRc(rc, 'Failed serviceCall.createGetMethod of uri ' || finalUrl) then do;
43 return;
44 end;
45
46 rc = serviceCall.executeMethod();
47 if 0 ne errorOnRc(rc, 'Failed serviceCall.executeMethod for uri ' || finalUrl) then do;
48 return;
49 end;
50
51 responseStatusCode = serviceCall.getStatusCode();
52
53 serviceCall.getResponseBodyAsString(responseBody, rc);
54 if 0 ne errorOnRc(rc, 'Failed serviceCall.getResponseBodyAsString') then do;
55 return;
56 end;
57
58end;
59endpackage;
60

Path Parameters

NameTypeRequiredDescription
restApiDefinitionId
string
true

The identifier for the REST API definition.

revisionId
string
true

The identifier for the revision of the REST API definition.

Query Parameters

NameTypeRequiredDescription
codeTarget
string
false

The type of platform or scenario in which the generated code is used. The following are code targets:

  • microAnalyticService - Use this type when the generated DS2 is going to be run in SAS Micro Analytic Service.
  • others - Use this target type in all other cases.
Allowed values:
microAnalyticServiceothers

Responses

StatusMeaningDescription
200OK

The request succeeded.

HeadersSchema
404Not Found

No code for the revision of the REST API definition exists at the requested path.

HeadersSchema