What is the ResourceURL I have to pass if my resource(.jsc) is placed in An organizational level

Not applicable

My resource name is pathSetter and i placed my ResourceURL as jsc://pathSetter.js where I didn't placed my URL in a proxy level.It is placed in Organizational level.So I am getting an error like Invalid resource url ref jsc://pathSetter.js in policy JavaScript-1 in sonia_gella_test.

So any one can help me what is url i have to give in ResourceURL to call a .js resource which is stored in organizational level

Solved Solved
0 8 1,965
1 ACCEPTED SOLUTION

Thanks for the detailed screenshots, Sonia.

Looks like it might be the name of your org-scoped resource. The name doesn't have the .js extension.

Try deleting the resource with this API, then re-import the resource to the org, naming it pathSetter.js.

After that, I'm guessing you can do the steps to export the proxy, delete the resource, and re-import the proxy.

If that doesn't work, click the Open a Ticket button next to the search box at the top of the page.

View solution in original post

8 REPLIES 8

Not applicable

Hi Sonia,

You'll need to refer to the resource as it is defined in the organizational scope, e.g.

<ResourceURL>jsc://pathSetter</ResourceURL>

Regards,

Dave

Hi Sonia -

Just tagging onto this with a couple more details.

First, use this API to make sure the resource is at the org level:

http://apigee.com/docs/management/apis/get/organizations/%7Borg_name%7D/resourcefiles

But I'm sure you've already checked. If so, the main reason I wanted to chime in is to describe the current behavior of the management UI, if that's what's tripping you up. When you add a policy with a resource in the management UI, you're asked to import or create a resource (at the API proxy scope), even if you already have that resource at the org or environment scope. And when you try deleting the script on the proxy, you'll get a validation error.

To get around this, export the proxy via Project > Download Current Revision. Then unzip it and delete the resource file. Zip the proxy bundle back up, and use Project > Import into New Revision. When you redeploy the proxy (this time without the resource), Apigee should be able to find your org-scoped file with just the jsc://pathSetter.js reference.

This topic describes how Apigee walks up the scope hierarchy looking for named resources:

http://apigee.com/docs/api-services/content/resource-files#resourcenameresolution

Floyd

Not applicable

Thanks for your reply Dave and Floyd.

--Dave

I gave my ResourceURL as you said only.Still I am getting this problem.

--Floyd

I tried as you said Floyd.But there is no difference in the error message when I am Trying to deploy my new revision into test environment.

As you said I deleted the local .js file by importing the bundle into my local machine and I deleted the .js file which is in proxy level and again I placed in my organization.And I tried it to deploy into my Test environment then it gives me with the following errror

Invalid resource url ref jsc://pathSetter.js in policy JavaScript-1

And I also checked whether resource is placed in my organization or not -It is successfully placed .

Hi Sonia -

I can reproduce that error when I change the filename in the resourceURL to not match the exact filename (with extension) of a proxy-scoped resource.

The only thing I can think of at this point is to double-check to make sure the org-scoped resource filename exactly matches the resourceURL, and that the resource type returned in the API call is jsc.

If all that checks out but still isn't working, and you have a support contract, please file a support ticket. We do have a product bug filed for this issue.

As a last-ditch workaround, maybe try doing things in this order with a new policy:

1. Delete your existing JS policy.

2. Add a new JS policy to your proxy, and and create a new proxy-scoped JS resource.

3. Add the exact same resource at the org level.

4. Export the proxy, delete the resource file, re-zip the proxy, and re-deploy the zip.

If that ends up working for you, note that trying to make changes to the proxy and redeploying will probably result in a Resource Not Found error on the org-scoped resource. (Again, there's a bug filed for this.)

Thanks,

Floyd

Not applicable

Hi Floyd-

I just followed Your steps as you said.

Below is my implementation

1.Showing my organizational resources first here

I run this command in curl :curl -k https://api.enterprise.apigee.com/v1/organizations/{myorg}/resourcefiles with my credentials

113-orgres.png

2.Created a proxy with Javascript policy by placing sample.js file in proxy scope first.

3.Now I Exported the proxy, deleted the resource file, re-zip the proxy

4.Now I tried to deploy it into test environment.

114-3.png

Please let me Know If I have done anything wrongly

And I also want to open a support ticket on this.Please let me know how to open a support ticket.

Thanks for the detailed screenshots, Sonia.

Looks like it might be the name of your org-scoped resource. The name doesn't have the .js extension.

Try deleting the resource with this API, then re-import the resource to the org, naming it pathSetter.js.

After that, I'm guessing you can do the steps to export the proxy, delete the resource, and re-import the proxy.

If that doesn't work, click the Open a Ticket button next to the search box at the top of the page.

Not applicable

Thanks Floyd,Now it's working.It's reaching the org-scoped resource.

But It's Showing an error i.e

Compilation of JavaScript jsc://SettingHeader1.js failed with error:Compilation error: unterminated string literal (JavaScript_1#1). Line:1, column:31. Source is:'request.setHeader(RequestPath,. Context Revision:1;APIProxy:Sample_javascript_rev1_2015_02_18;

Actually to import the resource I am running a curl command i.e

curl -X POST -k -H "Content-type:application/octet-stream" -d 'request.setHeader("RequestPath", flow.getVariable("proxy.basepath"));' https://api.enterprise.apigee.com/v1/organizations/{myorg}/resourcefiles?"name=SettingHeader1.js&typ... with my credentials.

while executing this command I am getting response like below

118-6.png

Here I am attaching my error

116-4.png

May I know is I am passing the data of the org-resource with -d option is correct or not.Because it is showing an error like unterminated string literal .I am following the below link to write that curl command

http://apigee.com/docs/api-services/content/resource-files

Please let me know where I am doing wrong

Sonia - You definitely uploaded it correctly with -d. This might be a bug. I tried a simpler example, creating a yearSetter.js with

var year = context.getVariable('system.time.year');

That worked for me at the proxy scope, but the framework can't find 'system'.

Please "Open a Ticket" at the top of this page.

Sorry I couldn't get you all the way through it!

Floyd