Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Point in time restore call fails with status code 422 - unprocessable_entity #94

@shrayasr

Description

@shrayasr

Hi,

At the outset, thank you for such a great client. Clients make interacting with APIs so seamless and quick.

Problem

A few days ago, I was using this client in order to do a point in time restore of a managed DB on our account. Here is the API documentation for that particular call.

My request looked like this:

	var restoreDBRequest = new DatabaseBackup
	{
		Name = "db-restored-from-API",
		Engine = "pg",
		Version = "10",
		Size = "db-s-1vcpu-2gb",
		Region = "blr1",
		NumNodes = 2,
		Tags = new List<string>(),
		BackupRestore = new DatabaseBackupRestore
		{
			DatabaseName = "existing-db",
			CreatedAt = new DateTime(2021, 02, 20, 16, 45, 0)
		}
	};

Which constantly threw the error with a status code 422:

{"message":"invalid json body","id":"unprocessable_entity","request_id":"XXXXX"}

Using this information, I contacted digital ocean's support for a resolution and after much back and forth it has been solved. As per them

  1. The name of the restored db cannot contain capital letters.
  2. The timestamp should be in ISO8601 format.

I made these 2 changes and executed the request:

	var restoreDBRequest = new DatabaseBackup
	{
-		Name = "db-restored-from-API",
+		Name = "db-restored-from-api",
		Engine = "pg",
		Version = "10",
		Size = "db-s-1vcpu-2gb",
		Region = "blr1",
		NumNodes = 2,
		Tags = new List<string>(),
		BackupRestore = new DatabaseBackupRestore
		{
			DatabaseName = "existing-db",
-			CreatedAt = new DateTime(2021, 02, 20, 16, 45, 0)
+			CreatedAt = new DateTime(2021, 02, 20, 16, 45, 0, DateTimeKind.Local)
		}
	};

And I was successfully able to restore my DB to the point in time that I wanted.

Issue

  1. Do you think it makes sense to run a .ToLower() on the DatabaseBackup.Name field?
  2. Do you think it makes sense to throw an exception if the Kind property of DatabaseBackupRestore.CreatedAt is Unspecified?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions