Skip to content

Instantly share code, notes, and snippets.

@mikekistler
Created March 24, 2022 22:29
Show Gist options
  • Save mikekistler/306e95ad554bc1a0b48fc23f531044b3 to your computer and use it in GitHub Desktop.
Save mikekistler/306e95ad554bc1a0b48fc23f531044b3 to your computer and use it in GitHub Desktop.
Example of DPG method call in C#
string newProjectName = "MyProject";
RequestContent creationRequestContent = RequestContent.Create(
new {
description = "This is the description for a test project",
language = "en",
multilingualResource = false,
settings = new {
defaultAnswer = "No answer found for your question."
}
}
);
try {
Response creationResponse = client.CreateProject(newProjectName, creationRequestContent);
var doc = JsonDocument.Parse(creationResponse.Content.ToMemory());
var creationDate = doc.RootElement.GetProperty("createdDateTime");
Console.WriteLine($"\nSuccessfully deployed {newProjectName} on {creationDate}.");
}
catch (RequestFailedException e)
{
Console.WriteLine(e);
throw;
}
@annelo-msft
Copy link

var creationDate = doc.RootElement.GetProperty("createdDateTime");

You may need to cast this to print it correctly.

I think it would help illustrate the point if you showed the expected JSON returned from CreateProject.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment