There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CreateOpportunity
with an AWS SDK
The following code example shows how to use CreateOpportunity
.
- SDK for .NET
-
Create an opportunity.
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // PDX-License-Identifier: Apache-2.0 using System; using Newtonsoft.Json; using Amazon; using Amazon.Runtime; using Amazon.PartnerCentralSelling; using Amazon.PartnerCentralSelling.Model; namespace AWSExample { class Program { static readonly string catalogToUse = "AWS"; static async Task Main(string[] args) { // Initialize credentials from .aws/credentials file var credentials = new Amazon.Runtime.CredentialManagement.SharedCredentialsFile(); if (credentials.TryGetProfile("default", out var profile)) { AWSCredentials awsCredentials = profile.GetAWSCredentials(credentials); var client = new AmazonPartnerCentralSellingClient(awsCredentials); var request = new CreateOpportunityRequest { Catalog = catalogToUse, Origin = "Partner Referral", Customer = new Customer { Account = new Account { Address = new Address { CountryCode = "US", PostalCode = "99502", StateOrRegion = "Alaska" }, CompanyName = "TestCompanyName", Duns = "123456789", WebsiteUrl = "www.test.io", Industry = "Automotive" }, Contacts = new List<Contact> { new Contact { Email = "test@test.io", FirstName = "John ", LastName = "Doe", Phone = "+14444444444", BusinessTitle = "test title" } } }, LifeCycle = new LifeCycle { ReviewStatus = "Submitted", TargetCloseDate = "2024-12-30" }, Marketing = new Marketing { Source = "None" }, OpportunityType = "Net New Business", PrimaryNeedsFromAws = new List<string> { "Co-Sell - Architectural Validation" }, Project = new Project { Title = "Moin Test UUID", CustomerBusinessProblem = "Sandbox is not working as expected", CustomerUseCase = "AI Machine Learning and Analytics", DeliveryModels = new List<string> { "SaaS or PaaS" }, ExpectedCustomerSpend = new List<ExpectedCustomerSpend> { new ExpectedCustomerSpend { Amount = "2000.0", CurrencyCode = "USD", Frequency = "Monthly", TargetCompany = "Ibexlabs" } }, SalesActivities = new List<string> { "Initialized discussions with customer" } } }; try { var response = await client.CreateOpportunityAsync(request); Console.WriteLine(response.HttpStatusCode); string formattedJson = JsonConvert.SerializeObject(response, Formatting.Indented); Console.WriteLine(formattedJson); } catch (ValidationException ex) { Console.WriteLine("Validation error: " + ex.Message); } catch (AmazonPartnerCentralSellingException e) { Console.WriteLine("Failed:"); Console.WriteLine(e.RequestId); Console.WriteLine(e.ErrorCode); Console.WriteLine(e.Message); } } else { Console.WriteLine("Profile not found."); } } } }
-
For API details, see CreateOpportunity in AWS SDK for .NET API Reference.
-