Exporting database in JSON format is unavailable via url request

Hello,
I’m trying to export the Dgraph database in JSON format with the following URL on localhost -

http://localhost:8080/admin/export?format=json

With the above URL, the data is always getting exported in RDF instead of JSON, It should be a JSON export as here I have selected the format JSON, I don’t understand what’s wrong here with the above URL request or what should be the correct URL here for JSON export :thinking: Does anyone know about such issue.

Hi Prateek, you could fire a mutation to the alpha; this should work.

http://localhost:8080/admin

mutation {
  export(input: {format: "json"}) {
    response {
      message
      code
    }
  }
}

Hi @anand,
Thanks, This is working, Could you tell me is it possible to achieve the same result via URL request, It is exporting the data in RDF. So, I think it should be possible to do the same with JSON.

Hi, you could convert the graphql call to a post like below. I am not sure if we have a direct URL request option.

curl --location --request POST 'http://localhost:8080/admin' --header 'Content-Type: application/json' --data-raw '{"query":"mutation {\n  export(input: {format: \"json\"}) {\n    response {\n      message\n      code\n    }\n  }\n}","variables":{}}'
1 Like

These HTTP endpoints gonna be deprecated soon. I have plans to make a small JS code to create legacy support. But is better to try to move to GraphQL right away.

1 Like