HTTP "POST" Error in XCODE

Hello,

Using this WIX code in the http-function:

// Submission Test
let swiftList = “SwiftSubmissionTest” ;

export function post_swiftsubmissionapi ( request ) {
const response = {
“headers” : {
“Content-Type” : “application/json” ,

} 

};

// Get name of Data Collection from path[0]
let swiftCollection = request.path [ 0 ]; // “DummyData”

if ( swiftList . includes ( swiftCollection )) {
return wixData . insert ( swiftCollection )
//.limit(1000)
//.find()
. then ( async ( apiResults ) => {
const swifttItem = apiResults.items [ 0 ]

  **if**  ( apiResults.totalCount  >  0 ) { 
    response.body  = { 
      "id" :  swifttItem._id , 
      "firstName" :  swifttItem.firstName , 
      "lastName" :  swifttItem.lastName 

};

    **return**  ok ( response ); 
  } 
  response.body  = { 
    "items" :  "No items found in the collection." 
  }; 
  **return**  ok ( response ); 
}) 

}
response.body = {
“error” : “Data Collection is not allowed to be used through this API.”
};
return badRequest ( response );
}

I get the following error in XCODE for IOS:

“x-wix-code-user-error-details” = (
“{"isUserError":true,"code":"WD_VALIDATION_ERROR"}”
);
“x-wix-function-user-error” = (
“source=exception”
);
“x-wix-request-id” = (
“1670674501.2583154886188935”
);

Please help as I need to be able to populate my WIX database with from my IOS app. Its been an ongoing issue, so its a bit a of an emergency now. I like WIX but is I don’t get this issue resolved we will have to go fully IOS without the use of an integrated web solution. Your help will be highly appriciated. I’m sure every IOS developer would love to get this info as I don’t see a solution anywhere-else on the web. This would be huge for us.

Thanks in advance!

wixData . insert ( swiftCollection, item )

You need to provide an item in object type!

So I tried this which has the item I believe, but I still get nothing

export function post_swiftsubmissionapi ( request ) {
let options = {
“headers” : {
“Content-Type” : “application/json”
}
};
// get the request body
return request.body . text ()
. then ( ( body ) => {
// insert the item in a collection
return wixData . insert ( “SwiftSubmissionTest” , JSON . parse ( body ));
} )
. then ( ( results ) => {
options.body = {
“id” : results._id ,
“firstName” : results.firstName ,
“lastName” : results.lastName
};
return created ( options );
} )
// something went wrong
. catch ( ( error ) => {
options.body = {
“error” : error
};
return serverError ( options );
} );
}

here is the new error:

);
“x-wix-function-user-error” = (
“source=response”
);
“x-wix-request-id” = (
“1670766930.9353141962221326479”
);
} }