-1

given below is the response json im getting.

 {
      "result": {
          "files": {
              "docType1": {
                  "fileFound": true,
                  "details": {
                      "name": "Aadhaar Card",
                      "type": "file",
                      "size": "",
                      "date": "...date...",
                      "parent": "",
                      "mime": [
                      "application/pdf",
                      "application/xml", //Optional
                      "application/json" //If available
                      ],
                      "doctype": "...5 letter DOC key...",
                      "description": "...Description...",
                      "issuerid": "...issuer id...",
                      "issuer": "...issuer name...",
                      "id": "...unique file ID...",
                      "uri": "...unique file URI..."
                      "file": {
                          "pdf": "...direct url to download pdf...",
                          "xml": "...direct url to download xml..." // where available
                      }
                  }
              },
              "docType2": {
                  fileFound: true/false,
                  "details": {}
              }
          }
      }
  }

and I need to send the list of data inside file{} to my backend In this body json is given below

{

"admission_letter":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "cv_resume":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "photo":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "kyc_doc":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "pan_card":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "passport_front":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "passport_back":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "entrance_score_card":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", "language_score_card":"https://cynapse.co.in/wp-admin/admin.php?action=tripetto-attachment&reference=e1dc5e4758edaadb700e8cfa974d1451a29408a040e23ba0db002dcc5b406754", }

How will I POST the dynamic list to my api

1 Answers1

0

Try to refer below code :

addData(String  admission_letter) async {
  Map data = {
  'admission_letter': admission_letter
 };

 String body = json.encode(data);
 var response = await http.post(
 Uri.parse("your url here"),
  body: body,
  headers: {
    "Content-Type": "application/json",
    "accept": "application/json",
  },
 );
 if (response.statusCode == 200) {
  print("Saved");
  } else {
  print("Error");
  }

}
Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40