locked
Save Error: Data invalid please refresh the page and try again RRS feed

  • Question

  • Hello,

    I've already added a custom API and published it, it's on my phone and PC no problem. There's only a few records in the DB as I'm learning. Today I added a new column, an image column that I've saved a byte[] array image to using the API. When I try to edit my custom API section and add this new column, select image as its data type, saving tells me the above error. Even if I leave the new column out and remove one of the old columns that are already working and published so that I can hit save, I still get the same save error even though I'm using only one column that has already worked.

    So is this image column not supported even though there is an image data type? And even if I don't use that column I can no longer use that API connected to that DB?

    I don't see how else to use an image and it seems that this is supported so why would it not be working? Any answers would be great as there's not much documentation explaining these data types and usage for custom API's, just how to use the WordPress API when that doesn't explain the developer stuff like column data types in databases.

    Thanks in advance,

    Daniel Jackson

    Thursday, June 29, 2017 2:11 AM

All replies

  • Hi Daniel,

    >And even if I don't use that column I can no longer use that API connected to that DB?

    Could you describe how you managed to implement your custom API with your databases before? And, where did you get the save error in App Studio or Visual Studio? As a result of my test, the image column should be supported in custom API section. If we can reproduce the same error, we can assist you better so you might as well provide screenshot if you will.

    It will be better to complete this through Visual Studio as it will provide debugging tool which helps a lot.

    Best regards,

    Mattew Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Thursday, June 29, 2017 6:15 AM
    Moderator
  • I'm adding a shared linked of five screenshots which were too large to post here. They are labeled 1, 2, 3... in order. Hopefully that explains better what I explained above. It seems pretty basic here. I haven't even gotten into half the stuff that App Studio is supposed to do so it would be a shame if I couldn't continue.

    I could try to debug via source code, my concern is that I wouldn't know what I'm supposed to do. I was going to get the code after I got as far as I could in App Studio. It might be really easy for someone else here but I've never done these things before and App Studio has gotten me further than I ever have before. So source was a last resort. I figured someone must know how to use the image data type in the custom API binding choices if the Db has a column type of image as well.

    The way I managed to add my custom API before was straight forward. I clicked custom API and started going through the wizard. Adding two columns that you'll see in the screenshots. Very simple and basic, nothing fancy or major. Just as you would add a custom API if you were to click it and go through the steps.

    Custom API Screenshots


    • Edited by DanJ210 Thursday, June 29, 2017 8:27 PM Minor grammatical fixes.
    Thursday, June 29, 2017 1:19 PM
  • If anyone knew how I am supposed to include images or where there is documentation on each feature of the Custom API section along with documentation on what the data types are and what they require from a Db. If image in App Studio does not work with image in Db then what does it work with? Stuff like that.

    Thanks in advance.

    Thursday, June 29, 2017 8:28 PM
  • If you want to replicate this. Create a Db on Azure with a single table and two columns. Name, and Price. Name is VarChar() and Price is Double. Give it some records. I then have a simple API on Azure that gives back all records or one of the records via a passed ID. Set up the connection via the API to a Custom API section in App Studio, save it, and then publish and run the app which everything should work no problem.

    Now add a new image column to the table so there's now three columns... Name, Price and {image column name}. Add an image to the column for any record or all records. I used a method in the API to manually read in a .jpg file from FileStream, copy that to a byte[] array and then save that to a record using Entity which saves it into the database.

    Go back to App Studio and edit the already saved and working Custom API section. Then go through the wizard and try to add the image column and upon hitting the save button in the top right corner, you should see the error... You can also try to remove one of the two columns, either Name or Price, and try to save yet still get the error.

    So that's how you can reproduce.

    I know this works because I do this at a company to store .wav and .vox files which get stored and pulled. Below is the code I used in the API to add an image to a record. It worked no problem. I do this at work to store and pull .wav and .vox files.


    `        [HttpGet("{id}")]
            public async Task<Metals> Get(int id) {
                string filePath = "C:\\Users\\DanJ2\\OneDrive\\WebSite HTML Files\\Florida Recycling Site\\escrap.jpg";
                var metal = await _repository.GetMetalAsync(id);
                using (var stream = new FileStream(filePath, FileMode.Open)) {
                    byte[] byteImage = new byte[stream.Length];
                    await stream.ReadAsync(byteImage, 0, (int)stream.Length);
                    metal.CommodityImage = byteImage;
                    await _repository.SaveChangesAsync();
                }
                return metal;
            }`
    • Edited by DanJ210 Thursday, June 29, 2017 8:48 PM Adding code for image storage in database.
    Thursday, June 29, 2017 8:46 PM
  • Hi Daniel,

    Sorry for the delayed response.

    Regarding the save error and adding image as column type, please send an email to App Studio team: windowsappstudio@microsoft.com .

    Best regards,

    Mattew Wu 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 4, 2017 9:50 AM
    Moderator