Beispiel #1
0
        public static void DeleteNote(ISimpleJsonRest web, SimpleNote note)
        {
            if (note.ID == "")
            {
                throw new SimpleNoteAPIException("Cannot delete a not uploaded note");
            }
            note.ModificationDate = DateTimeOffset.Now;

            APIDeleteNoteData data = new APIDeleteNoteData
            {
                deleted = true
            };

            try
            {
                web.PostUpload(data, "note/i/" + note.ID, new[] { 412 });
            }
            catch (RestStatuscodeException e1)
            {
                if (e1.StatusCode == 400 && !string.IsNullOrWhiteSpace(e1.HTTPContent))
                {
                    var req = web.ParseJsonOrNull <APIBadRequest>(e1.HTTPContent);
                    if (req != null)
                    {
                        throw new SimpleNoteAPIException($"Server returned status 400.\nField: '{req.field}'.\nMessage: '{req.message}'", e1);
                    }
                }

                throw;
            }
        }