Created
March 24, 2022 22:29
-
-
Save mikekistler/306e95ad554bc1a0b48fc23f531044b3 to your computer and use it in GitHub Desktop.
Example of DPG method call in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.