cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mira_Ghaly
Dual Super User II
Dual Super User II

Azure Web API and CDSWebApiService Class

Hello,

 

I am creating a an Azure API that connects to the CDS Web API and I am trying to use the class CDSWebApiService mentioned in the samples below:

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/samples/cdswebapiser...

 

I have rebuilt all code in my API Project but the case that when i use the post to create a contact based on the sample , although the contact is physically created but there is no response getting back

 

 

 

 

 

            string connectionString = ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

            ServiceConfig config = new ServiceConfig(connectionString);
            using (CDSWebApiService svc = new CDSWebApiService(config))
            {
                //  Console.WriteLine("--Starting Basic Operations--");

             
        ////Create a contact
        var contact1 = new JObject
                        {
                            { "firstname", "Rafel" },
                            { "lastname", "Shillo" }
                        };
                Uri contact1Uri = svc.PostCreate("contacts", contact1);
                return contact1Uri.AbsolutePath;
            }

 

 

 

 

 

Any Help will be appreciated !

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
2 REPLIES 2

I suspect there may be an issue with the async implementation that you are using - can you try and implement the call using the PostCreateAsync method?

@ScottDurow 

I tried to use PostCreateAsync but it returned an Exception Task was cancelled.

 

This is how i call it from my API , it just never returns the URI 

public string Post([FromBody]string value)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
            ServiceConfig config = new ServiceConfig(connectionString);

            using (CDSWebApiService svc = new CDSWebApiService(config))
            {
                //  Console.WriteLine("--Starting Basic Operations--");

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

                //Create a contact
                var contact1 = new JObject
                        {
                            { "firstname", "Mira" },
                            { "lastname", "WEB API" }
                };
               return svc.PostCreate("contacts", contact1).ToString();

           
            }
         
            
        
           

        }
If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (56,875)