Can you upload or retrieve the details of the resource files ( JavaScript and XSLTs) at organization or environment level

amar333n
Participant III

I want to upload the details of the resource files ( JavaScript and XSLTs) at organization or environment level and use the resource files in all proxies.

Is it possible?

Solved Solved
0 3 452
1 ACCEPTED SOLUTION

amar333n
Participant III

Yes, we can upload the resource files in environment and organization.

Curl for creating the resource file in environment

curl -X POST -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {BasicAuth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/resourcefiles?name={name_of_the_file}&type={xslt/jsc}"

Curl for creating the resource file in Organization

curl -X POST -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {BasicAuth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/resourcefiles?name={name_of_the_file}&type={xslt/jsc}"

Curl for updating the resource file in environment

curl -X PUT -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {Basic Auth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/resourcefiles/jsc/{name_of_the_file}"

Curl for updating the resource file in Organization

curl -X PUT -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {Basic Auth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/resourcefiles/jsc/{name_of_the_file}"

View solution in original post

3 REPLIES 3

aswinsegu
Participant IV

Hi Amar (@amar333n),

I hope this is what you are looking for

To List all resources in an org,

You can list all available resources by calling GET on the collection:

$ curl https://api.enterprise.apigee.com/v1/organizations/{org_name}/resourcefiles/{resource_type}

The following request lists all JavaScript resources at the organization level:

$ curl https://api.enterprise.apigee.com/v1/organizations/myorg/resourcefiles/jsc

The following request lists all JavaScript resources at the environment level, in the environment called prod:

$ curl https://api.enterprise.apigee.com/v1/organizations/myorg/environments/prod/resourcefiles/jsc

The following request lists all JavaScript resources in an API proxy revision (the most specific level):

$ curl https://api.enterprise.apigee.com/v1/organizations/myorg/apis/weatherapi/revisions/6/resourcefiles/j...

To create Resources,

To create a resource, you call the POST method, submitting the body of the resource file, and identifying the resource's name and type as query parameters.

To make the JavaScript available to API proxies running in any environment in your organization:

$ curl -X POST -H "Content-type:application/octet-stream"-d \
'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
https://api.enterprise.apigee.com/v1/organizations/myorg/resourcefiles?name=pathSetter.js&type=jsc \-u email:password

Note: Refer to the following Apigee Docs Resource Files

amar333n
Participant III

Yes, we can upload the resource files in environment and organization.

Curl for creating the resource file in environment

curl -X POST -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {BasicAuth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/resourcefiles?name={name_of_the_file}&type={xslt/jsc}"

Curl for creating the resource file in Organization

curl -X POST -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {BasicAuth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/resourcefiles?name={name_of_the_file}&type={xslt/jsc}"

Curl for updating the resource file in environment

curl -X PUT -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {Basic Auth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/resourcefiles/jsc/{name_of_the_file}"

Curl for updating the resource file in Organization

curl -X PUT -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -H "Authorization: Basic {Basic Auth}" -F "=@{FileName}" "https://api.enterprise.apigee.com/v1/organizations/{org}/resourcefiles/jsc/{name_of_the_file}"

how can I extend a environment level JavaScript resource file in a proxy so I could use functionality from environment level JS file and add more to it or override some of the functionality from env level js file.