I am using REST API C# to develop a tool. I would like to get project info based on owner name.
Does anyone have some sample code on how it should works?
Below is my code but it's not working.
Request ProjRequest = new Request("Projects");
ProjRequest.Workspace = "/workspace/xxx";
ProjRequest.Fetch = new List<string>()
{"Name"};
ProjRequest.Query = new Query("Owner.UserName", Query.Operator.Equals, "user name");
ProjResult result = restApi.Query(ProjRequest);
That looks pretty close. I think you just need to change the type to be singular:
Request ProjRequest = new Request("Project");
If that is still not working, inspect the Errors collection on the response and see what's wrong...
Related
I'm getting a Evernote.EDAM.Error.EDAMErrorCode.PERMISSION_DENIED error on createSharedNotebook when trying to share a business notebook.
AuthenticationResult busAuthResult = _userStore.authenticateToBusiness(authToken);
var bAuthToken = busAuthResult.AuthenticationToken;
var bNoteStoreUri = busAuthResult.NoteStoreUrl;
TTransport noteStoreTransport = new THttpClient(new Uri(bNoteStoreUri));
TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
var noteStore = new NoteStore.Client(noteStoreProtocol);
var notebook = noteStore.getNotebook(bAuthToken, notebookGuid);
var sharedNotebook = new SharedNotebook();
sharedNotebook.Email = "test#test.com";
sharedNotebook.NotebookModifiable = true;
sharedNotebook.AllowPreview = true;
sharedNotebook.NotebookGuid = notebookGuid;
noteStore.createSharedNotebook(bAuthToken, sharedNotebook);
The account I'm using has access to share the notebook, so I can't figure out where this error is coming from. I haven't been able to find anything on sharing business notebooks, so any ideas or links would be greatly appreciated!
I think NotebookModifiable is deprecated. Instead, can you add privilege? After that, hopefully you would get another error message that tell you exactly what other parameters like recipientSettings you have to add.
public ISearchResponse<object> GetById(string id) {
var uri = new Uri("<myendpoint>");
var settings = new ConnectionSettings(uri).DefaultIndex("useraction-*").PrettyJson().DisableDirectStreaming(); //or try _all
var client = new ElasticClient(settings);
var search = new SearchRequest<object>
{
Query = new TermQuery
{
Field = "field",
Value = "example"
}
};
var response = client.Search<object>(search);
return response;
}
I'm having trouble getting NEST to work. When I try to call the query defined above, I get the following error:
System.Exception: If you use a custom contract resolver be sure to subclass from ElasticResolver
at Nest.JsonExtensions.GetConnectionSettings(JsonSerializer serializer) in C:\Users\russ\source\elasticsearch-net-master\src\Nest\CommonAbstractions\Extensions\JsonExtensions.cs
I've searched the internet for mention of this and can't seem to find anything other than the source code. I've pretty much followed the documentation exactly so I don't know what to change.
Does anyone out there know what this error is trying to tell me? I feel like it's an error behind the scenes that I don't have control over.
I'm happy to answer additional questions if people need more info.
Thanks.
Also I don't know where that path is coming from in the exception because I have no user "russ"
I'm trying to use the InitiateFileTransferToGuest method to send a file to a VM. Unfortunately, I'm getting stuck. Here's the related code where VClient is the VimClient with an already successfull connection:
GuestOperationsManager VMOpsManager = new GuestOperationsManager(VClient, VClient.ServiceContent.GuestOperationsManager);
GuestFileManager VMFileManager = new GuestFileManager(VClient, VClient.ServiceContent.FileManager);
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, VClient.ServiceContent.AuthorizationManager);
NamePasswordAuthentication Auth = new NamePasswordAuthentication()
{
Username = "username",
Password = "password",
InteractiveSession = false
};
VMAuthManager.ValidateCredentialsInGuest(CurrentVM.MoRef, Auth);
System.IO.FileInfo FileToTransfer = new System.IO.FileInfo("C:\\userlist.txt");
GuestFileAttributes GFA = new GuestFileAttributes()
{
AccessTime = FileToTransfer.LastAccessTimeUtc,
ModificationTime = FileToTransfer.LastWriteTimeUtc
};
string TransferOutput = VMFileManager.InitiateFileTransferToGuest(CurrentVM.MoRef, Auth, "C:\\userlist.txt", GFA, FileToTransfer.Length, false);
First error shows up when getting to the ValidateCredentialsInGuest method. I get this message:
An unhandled exception of type 'VMware.Vim.VimException' occurred in VMware.Vim.dll Additional information: The request refers to an unexpected or unknown type.
If I remove that validation, I get the same error when trying to run InitiateFileTransferToGuest. I've been browsing the API documentation, and threads in VMware forums and a lot of places to be honest. The only pieces of code I've seen posted where it works were in Java and Perl, but the API implementation is a little different than C#. Any idea where to look?
Thank you!
I made it work after testing and making up stuff. I guessed the MoRef for both AuthManager and FileManager doing the following:
ManagedObjectReference MoRefFileManager = new ManagedObjectReference("guestOperationsFileManager");
GuestFileManager VMFileManager = new GuestFileManager(VClient, MoRefFileManager);
ManagedObjectReference MoRefAuthManager = new ManagedObjectReference("guestOperationsAuthManager");
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, MoRefAuthManager);
Now it's working, and I have no idea how.
I'm new to Octokit.Net.
and I want to create issue in my program...
So I coded like this.
var github = new GitHubClient(new ProductHeaderValue("Hello"));
var i = new NewIssue("asdf");
i.Body = "asdf";
var issue = github.Issue.Create("JoyLeeSoft", "test", i);
When I call Create function, function always throws NotFoundException.
And the error message just "Not Found"
But, the repository is avaiable. https://github.com/JoyLeeSoft/test
How can I solve this?
Creating an issue means being properly authenticated first (as in Tests/Authentication/BasicAuthenticatorTests.cs)
If not authenticated, the default response of GitHub can be "repository not found".
i am posting comments on my blog it works fine but there is one problem that i cannot post anonymous comments using XML-RPC by alexjamesbrown
instead of comment author there is name of admin
here is my code
var wrapper = new WordPressWrapper(textblogUrltemp + "/xmlrpc.php", adminunUser, adminPass);
var post = new Post();
post.title = toPost.VideoTitle;
post.dateCreated = Convert.ToDateTime(toPost.PostingDateTime);
post.description = toPost.VideoCode;
post.postid = wrapper.NewPost(post, true);
var comment = new Comment();
var wrap =new WordPressWrapper(textblogUrltemp + "/xmlrpc.php", adminunUser, adminPass);
comment.author = videoComments.userName;
comment.author_email = videoComments.email;
comment.content = videoComments.Comment;
wrap.NewComment(post.postid, comment);
I resolved it
var wrap =new WordPressWrapper(textblogUrltemp + "/xmlrpc.php", "", "");
also you need to modify the class-wp-xmlrpc-server.php file and in newComment function allow the anonymous comments
I bumped into this working for WP Remote Control. Very bad idea to unlock anonymous posting through XMLRPC. You can get flooded by Spam as anyone can do it.
The secret is to post the comment and edit it. Two requests but you're safe. There's a single method that does it in my class. Regards.
BTW: My class is PHP. I have it written in C++ too but it's too dependent to my C++ library to publish.