-
Notifications
You must be signed in to change notification settings - Fork 974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insufficient access; cannot execute Metadata operation with PAC enabled session id #6
Comments
That is worrying. I've not seen this in my demos recently. I'll look into it more. Is there something special about the user or context your VF page is running in? |
The only things that comes to mind are:
Thank you so much for your prompt reply, it is thoroughly appreciated. |
You maybe onto something here, perhaps Session ID's for packaging orgs are somewhat different? It is still frustrating that it appears to have changed I agree. Is it just VF pages or do the samples in MetadataServiceExamples from annoymous Apex calls also fail? |
After many hours of debugging I have finally found a 'solution'. This is definitely a very very strange issue. I copied all my test code into another development org and it ran without issue. I also have a test managed package org that I have used for proof of concept when submitting Salesforce bugs, I copied the same code into that org expecting it to fail... so of course it ran correctly. Which seems to rule out the possibility this is managed package related. I was able to run the MetadataServiceExamples through the developer console, so I started trying everything I could in the controller and page. I finally started to get closer when I commented out all the code in the action function and called the MetadataServiceExamples.createPage() method from the controller, a visualforce page was created! After more debugging I finally found a way to make this work, the MetadataService callouts need to be in static methods AND the static methods need to be in a separate class. I have found that UserInfo.getSessionId() returns different values depending on where it is called from. As demonstrated in the code snippet below
.
The debug outputs and the different session Ids (truncated for security purposes)
|
Scratch everything above. I have just come back to my computer having been auto logged out of my session and my unchanged previously working code is now failing again. So I have another hunch that maybe this is caused by being booted out of a session. Edit And at last I believe I have finally isolated the issue! Login and visit my visualforce page, wait for the session to expire It looks like I am going to have to log a case with Salesforce to get this investigated, I don't know how I'm going to get past level 1 with this :) Thanks again for your prompt replies Andrew, I will post the response from Salesforce (if I get one) into this issue |
I've asked my colleague Chris Peterson, who you will likely recognise from StackExchange to review this. As he actually has met something like this before. Hopefully Chris can shed some light! :) |
After a read over I'm convinced that my open case with salesforce about session Ids isn't quite the same issue, although the fact that we've hit two obscure sessionId related bugs in the platform at nearly the same time leads me to believe they recently did some work in that area on the platform itself. Daniel, have you opened up a case with salesforce on this? If so, can you give me the case number? We have an excellent partner premier support rep who I can work with to get this up to tier 3/R&D. |
I have just created a case for this. The case number is 08485985. Thanks once again for your spectacular help. you're right, I do recognise Chris from Stack Exchange :) But Andrew, I may have seen you around there once or twice as well :) |
Hi guys, First of all thank you both for the library and this post. I faced a similar issue using Andrew's library and was stuck. But finally found the resolution. The issue is when you are developing a managed package using the metadata api and have restricted API access, salesforce cannot handle the objects/structure which we provide a restricted access to and hence the error. I changed the API access from restricted to Unrestricted and it starts working again. |
Wow Vipul! Great Work! Thank you so much for posting, I have since had to shelve the project I was using this library for. But I am sure I would have run into this issue again, so it's nice to have a solution |
This is indeed great work, I'll call this out on the main README in fact! Thanks all! |
Spectacular and profound detective work! The same problem reared its head with the Spring '15 release and your discussion here floated to the top of the Google search results. Thank you guys! |
I'm still having this issue.
Are there other things I'm missing? |
Have you got any other Session Id restrictions enabled? |
@seeflat i'd like to close this one out, but if you want to pick this up again, please post back. 👍 |
I have been implementing a solution with you library (It is awesome thanks for all the work). I had my test working and creating visualforce pages successfully 2 days ago, now I am getting the exception message in the title.
I have tried googling this but could not find any information. Have you experienced this before?
The text was updated successfully, but these errors were encountered: