question

EduardoGomez-1870 avatar image
0 Votes"
EduardoGomez-1870 asked EduardoGomez-4998 commented

Intergrate Azure with xamarin table Error

Hello everyone

I am learning Azure, So after finishing my XamContact app, to work perfectly with SQLite

I decided to Integrate Azure, I already did all the CRUD operation methods, but I get an error when trying to insert in the People table

][1]][1]

As you can see I have a People table, but for some reason, when trying to get something out via Postman, I get an error

https://github.com/eduardoagr/XamContact // here is my code

So I don't know if I am calling the wrong table

here is my ASP web

https://github.com/eduardoagr/Azure

What I don't understand is that if my table is name people, why if I put people in Postman it doesn't get it, but if I put http://xamxontacts.azurewebsites.net/tables/person?ZUMO-API-VERSION=2.0.0 I can get

If you see, I have a people table
82923-image.png


dotnet-xamarinformsazure-mobile-app
image.png (31.0 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @EduardoGomez-1870 , could you please post the error log about this issue?And which Azure database service are you trying to integrate with ?

0 Votes 0 ·

As you can see, I have a table named83281-error-1.jpg people, but when I put it in postman, I get an ERROR



and for the xamarin forms app,

I get this

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

when I try to add a Contact, here is the code

https://github.com/eduardoagr/XamContact

0 Votes 0 ·
error-1.jpg (699.0 KiB)

I downloaded again the zumoappservices, from GitHub, and it still creates me a People Table, instead of Person, and in postam if I do
http://xamxontacts.azurewebsites.net/tables/person?ZUMO-API-VERSION=2.0.0

I can pregorm a GET, but If I put

http://xamxontacts.azurewebsites.net/tables/People?ZUMO-API-VERSION=2.0.0

here is my backend

https://github.com/eduardoagr/AzureBackEnd

0 Votes 0 ·
Show more comments

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered EduardoGomez-4998 commented

You're using Entity Framework migrations to create/update the database schema; https://github.com/eduardoagr/AzureBackEnd/blob/729cf33c16849ebeddc5c072a1f35162784c8db0/ZUMOAPPNAMEService/App_Start/Startup.MobileApp.cs#L26.

 var migrator = new DbMigrator(new Migrations.Configuration());
 migrator.Update();

It will pluralize Dto's to table names; check out this blog post. However, what's odd is when checking your repo, you don't have a "Person"/"People" object in the context, it's called contacts. I even checked your migrations and the table created is Contacts. You also have ContactController in the PersonController filename. It's not decorated with [MobileAppController] which may affect offline sync but should be fine for making request from Postman. Instead of person/people, try making the request to /contacts and see if you still get the error. If you still get an error, then how did you create the database to begin with?


· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes I change it now and did a little console application to try it out, and it works perfectly I do not understand however why when checking the database, I have to put Contact instead of contacts if my DB in azure is name contracts

0 Votes 0 ·

by the way, if you do this is potman, it will work

http://xamxontacts.azurewebsites.net/tables/contact?ZUMO-API-VERSION=2.0.0

I made this console app, just to tested it, and works fine

using AzureTest;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;


const string Url = "http://xamxontacts.azurewebsites.net/tables/contact?ZUMO-API-VERSION=2.0.0";



using (HttpClient client = new HttpClient()) {

 var request = await client.GetAsync(Url);
 if (request.IsSuccessStatusCode) {

     var content = await request.Content.ReadAsStringAsync();
     var res = JsonConvert.DeserializeObject<List<Contacts.Contact>>(content);

     foreach (var item in res) {

         Console.WriteLine(item.name);
     }
 }

}

but when I go to Xamarin, it doesn't read, or add, or update or delete

0 Votes 0 ·

the database was created by Microsoft, is in the azure getting started github

0 Votes 0 ·
Show more comments