Learning While Aging

How to fix SharePoint query error-cannot complete this action please try again

This SharePoint query error kept me busy for a while because the error message is very generic and useless, so I hope my experience can help someone in the future. When I ran my ASP.NET application to query a specific resource item from a SharePoint list the other day, I got this error message:

Cannot complete this action.

Please try again.

You can see that this error is very generic and it didn’t provide much information about what went wrong, and the stack trace of the error only shows which line caused the problem.

SharePointError

Below is a screenshot of my source code.

SharePointErrorSourceCode

I also stepped into my source code many times but still could not figure out what the root cause of this error, until hours later I suddenly noticed there is a typo in my query string as shown in the following screenshot:

SharePointQueryTypo

As shown above, I missed a “<” in the close tag </Where> for my CamlQuery and the malformatted query caused ExecuteQuery() to fail, but I am surprised it does not give much helpful information of the exception caused by a malformatted query.

Anyway, after I fixed the query, the error went away. I hope my experience can save you some time if you happen to encounter the same exception error in your .NET application.

2 2 votes
Article Rating
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Peter Bowers
Peter Bowers
6 years ago

NOTE: I am editing and replacing all angle-brackets with parentheses because angle-brackets are not accepted in comments here. Hopefully it still makes sense. I got the same error because I was attempting to put more-than-two elements inside an (Or)…(/Or) In other words I was trying to do (Or)(Eq)…(/Eq)(Eq)…(/Eq)(Eq)…(/Eq)(/Or) (that’s with 3 – it was dynamic so sometimes I had a lot more than that) And I got the same generic error message. Just mentioning it here in case someone else runs across the same problem. The solution, of course, is that (Or) and (And) can only combine 2 arguments so… Read more »