cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

How to send multiple records in Create WebAPI in PowerApps Portal

Hello

How Can I send multiple records in Create WebAPI?

Create API with single records working fine but with multiple records giving error

If I sending multiple records , getting error code 500, An unexpected error occurred while processing the request

WebAPI reference Link
https://docs.microsoft.com/en-us/powerapps/maker/portals/web-api-perform-operations

Please check below code 

function addSampleRecord() {
            //Sample data to create a record - change as appropriate
            var recordObj = [{
                firstname: "Willie",
                lastname: "Huff" + _.random(100, 999)
         
            },{
                firstname: "Andrew",
                lastname: "Huff" + _.random(100, 999)

            }];
            appAjax('Adding...', {
                type: "POST",
                url: "/_api/contacts",
                contentType: "application/json",
                data: JSON.stringify(recordObj),
                success: function (res, status, xhr) {
                    recordObj.id = xhr.getResponseHeader("entityid");
                    recordObj.fullname = recordObj.firstname + " " + recordObj.lastname;
                    table.addRecord(recordObj);
                }
            });
            return false;
        }


 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Impactful Individual
Impactful Individual

Re: How to send multiple records in Create WebAPI in PowerApps Portal

Hi @Dhananjay_Patil 

 

Bulk creation is still not available in PowerApp Portal.

You can create a record one by one. Please refer below code:

var recordList = [];

var obj1 = { firstname: "Willie", lastname: "Huff" };
var obj2 = { firstname: "Andrew", lastname: "Huff" };

recordList.push(obj1);
recordList.push(obj2);

for (var i = 0; i < recordList.length; i++) {
	webapi.safeAjax({
		type: "POST",
		url: "/_api/contacts",
		contentType: "application/json",
		data: JSON.stringify(recordList[i]),
		success: function (res, status, xhr) {
			alert("Success");
		},
		error: function (error) {
			alert(error);
			console.log(error);
		}
	});
}

--------------------------
If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

View solution in original post

1 REPLY 1
Highlighted
Impactful Individual
Impactful Individual

Re: How to send multiple records in Create WebAPI in PowerApps Portal

Hi @Dhananjay_Patil 

 

Bulk creation is still not available in PowerApp Portal.

You can create a record one by one. Please refer below code:

var recordList = [];

var obj1 = { firstname: "Willie", lastname: "Huff" };
var obj2 = { firstname: "Andrew", lastname: "Huff" };

recordList.push(obj1);
recordList.push(obj2);

for (var i = 0; i < recordList.length; i++) {
	webapi.safeAjax({
		type: "POST",
		url: "/_api/contacts",
		contentType: "application/json",
		data: JSON.stringify(recordList[i]),
		success: function (res, status, xhr) {
			alert("Success");
		},
		error: function (error) {
			alert(error);
			console.log(error);
		}
	});
}

--------------------------
If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (6,749)