To determine the database_username part of the table name just look at the json for any layer in your AGOL.This is the same for every layer/fs in your AGOL and doesn't change. Although I don't think it matters if you use the wrong one.
Below is JSON what will work and the steps involved. As a quick test, create a test feature service and see if you can add it.
You said above that you were able to successfully add a layer? Where/when is the 400 exception error occuring? It sounds like you are actually having trouble adding the layer in the first place. If so, it's probably poor json. The easiest thing to do is to copy the json from an existing feature layer and edit it.
An easy way is to first create the layer you want to add to your existing feature service as a new, seperate feature service. Define the fields etc. in Arcgis Pro or in AGOL, then just copy the json that AGOL creates for you.
So for example, here is a simple point layer I created in AGOL. Create you own layer with the fields etc. that you need.

View the feature service in and switch to Admin mode (link in top right):

Open the layer you want to "copy" to your existing feature service and view and copy the raw json:


Edit the json:
1. Add { "layers" : [ to the beginning
2. Add corresponding closing brackets to the end ]}
3. Change the "Name" (Row 19)
3. Optional: Change the Layer ID (Row 15) to whatever number you want. If you leave it at 0 AGOL will just assign a layer id to it that doesnt' conflict with any other layers in the feature service
{ "layers" : [
{
"adminLayerInfo" : {
"tableName" : "db_72280.user_72280.Test_Point_Layer_TESTING",
"geometryField" : {"name" : "Shape"},
"xssTrustedFields" : ""
},
"id" : 0,
"enableUseOfScaleOutReplicasWhenEditable" : true,
"name" : "Testing",
"type" : "Feature Layer",
"serviceItemId" : "e662b9687e584b07916701428c21c0dc",
"displayField" : "",
"description" : "",
"copyrightText" : "",
"defaultVisibility" : true,
"editingInfo" : {
"lastEditDate" : 1658654341208
},
"relationships" : [],
"isDataVersioned" : false,
"hasContingentValuesDefinition" : false,
"supportsAppend" : true,
"supportsCalculate" : true,
"supportsASyncCalculate" : true,
"supportsTruncate" : true,
"supportsAttachmentsByUploadId" : true,
"supportsAttachmentsResizing" : true,
"supportsRollbackOnFailureParameter" : true,
"supportsStatistics" : true,
"supportsExceedsLimitStatistics" : true,
"supportsAdvancedQueries" : true,
"supportsValidateSql" : true,
"supportsCoordinatesQuantization" : true,
"supportsLayerOverrides" : true,
"supportsTilesAndBasicQueriesMode" : true,
"supportsFieldDescriptionProperty" : true,
"supportsQuantizationEditMode" : true,
"supportsApplyEditsWithGlobalIds" : false,
"supportsReturningQueryGeometry" : true,
"advancedQueryCapabilities" : {
"supportsPagination" : true,
"supportsQueryAttachmentsCountOnly" : true,
"supportsPaginationOnAggregatedQueries" : true,
"supportsQueryRelatedPagination" : true,
"supportsQueryWithDistance" : true,
"supportsReturningQueryExtent" : true,
"supportsStatistics" : true,
"supportsOrderBy" : true,
"supportsDistinct" : true,
"supportsQueryWithResultType" : true,
"supportsSqlExpression" : true,
"supportsAdvancedQueryRelated" : true,
"supportsCountDistinct" : true,
"supportsPercentileStatistics" : true,
"supportsSpatialAggregationStatistics" : true,
"supportedSpatialAggregationStatistics" : [
"EnvelopeAggregate",
"CentroidAggregate",
"ConvexHullAggregate"
],
"supportsQueryAttachments" : true,
"supportsLod" : true,
"supportsQueryWithLodSR" : false,
"supportedLodTypes" : [
"geohash"
],
"supportsReturningGeometryCentroid" : false,
"supportsQueryWithDatumTransformation" : true,
"supportsHavingClause" : true,
"supportsOutFieldSQLExpression" : true,
"supportsMaxRecordCountFactor" : true,
"supportsTopFeaturesQuery" : true,
"supportsDisjointSpatialRel" : true,
"supportsQueryWithCacheHint" : true,
"supportedOperationsWithCacheHint" : [
"query",
"queryTopFilter",
"queryAnalytics",
"queryAttachments",
"queryRelated"
],
"supportsQueryAttachmentsWithReturnUrl" : true,
"supportsQueryAnalytic" : true,
"supportsDefaultSR" : true,
"supportsFullTextSearch" : true
},
"advancedQueryAnalyticCapabilities" : {
"supportsLinearRegression" : true,
"supportsAsync" : true,
"supportsPercentileAnalytic" : true
},
"advancedEditingCapabilities" : {
"supportedSqlFormatsInCalculate" : [
"standard"
],
"supportsAsyncApplyEdits" : true,
"supportsReturnEditResults" : true
},
"infoInEstimates" : [
"extent",
"count"
],
"useStandardizedQueries" : true,
"geometryType" : "esriGeometryPoint",
"minScale" : 0,
"maxScale" : 0,
"extent" : {
"xmin" : -17811118.526923772,
"ymin" : -15538711.096309224,
"xmax" : 17811118.526923772,
"ymax" : 15538711.096309224,
"spatialReference" : {
"wkid" : 102100,
"latestWkid" : 3857
}
},
"drawingInfo":{"renderer":{"type":"simple","symbol":{"type":"esriPMS","url":"RedSphere.png","imageData":"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQBQYWludC5ORVQgdjMuNS4xTuc4+QAAB3VJREFUeF7tmPlTlEcexnve94U5mANQbgQSbgiHXHINlxpRIBpRI6wHorLERUmIisKCQWM8cqigESVQS1Kx1piNi4mW2YpbcZONrilE140RCTcy3DDAcL/zbJP8CYPDL+9Ufau7uqb7eZ7P+/a8PS8hwkcgIBAQCAgEBAICAYGAQEAgIBAQCAgEBAICAYGAQEAgIBAQCDx/AoowKXFMUhD3lQrioZaQRVRS+fxl51eBTZUTdZ41U1Rox13/0JF9csGJ05Qv4jSz/YPWohtvLmSKN5iTGGqTm1+rc6weICOBRbZs1UVnrv87T1PUeovxyNsUP9P6n5cpHtCxu24cbrmwKLdj+osWiqrVKhI0xzbmZ7m1SpJ+1pFpvE2DPvGTomOxAoNLLKGLscZYvB10cbYYjrJCb7A5mrxleOBqim+cWJRakZY0JfnD/LieI9V1MrKtwokbrAtU4Vm0A3TJnphJD4B+RxD0u0LA7w7FTE4oprOCMbklEGNrfdGf4IqnQTb4wc0MFTYibZqM7JgjO8ZdJkpMln/sKu16pHZGb7IfptIWg389DPp9kcChWODoMuDdBOhL1JgpisbUvghM7AqFbtNiaFP80RLnhbuBdqi0N+1dbUpWGde9gWpuhFi95yL7sS7BA93JAb+Fn8mh4QujgPeTgb9kAZf3Apd2A+fXQ38yHjOHozB1IAJjOSEY2RSIwVUv4dd4X9wJccGHNrJ7CYQ4GGjLeNNfM+dyvgpzQstKf3pbB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xLM33NCZRcPHOGJYZIKfpQyq7JjHS6yJjcHujLHADgkpuC7h8F8zEVqXSNC2awE69lqhs8AamkO26HrbDt2H7dBVQov2NcW26CiwQtu+BWjdY4n2nZboTbfCmKcCnRyDO/YmyLPnDlHvjDH8G6zhS9/wlEnYR7X00fWrFYuWdVI0ZpuhcbcczW/R2qdAcz6t/bRov4mONeaaoYl+p22rHF0bVNAmKtBvweIXGxNcfFH8eNlC4m6wMWMusEnKpn5hyo48pj9gLe4SNG9QoGGLAk8z5XiaJUd99u8122/IpBA2K9BGg2vWWKAvRYVeLzEa7E1R422m2+MsSTem97nSYnfKyN6/mzATv7AUgqcMrUnmaFlLX3ysM0fj+t/b5lQLtK22QEfyAmiSLKFZpUJ7kBRPXKW4HqCYynWVHKSG2LkyZex1uO1mZM9lKem9Tx9jjY5iNEYo0bKMhn7ZAu0r6H5PpLXCAq0rKJClSjSGynE/QIkrQYqBPe6S2X+AJsY2Ped6iWZk6RlL0c2r5szofRsO9R5S1IfQLRCpQL1aifoYFerpsbkuTImaUJXuXIDiH6/Ys8vm3Mg8L2i20YqsO7fItKLcSXyn0kXccclVqv3MS6at9JU/Ox+ouns+SF6Z4cSupz7l8+z1ucs7LF1AQjOdxfGZzmx8Iu1TRcfnrioICAQEAgIBgYBAQCAgEBAICAQEAgIBgYBAQCAgEBAICAQEAv8H44b/6ZiGvGAAAAAASUVORK5CYII=","contentType":"image/png","width":15,"height":15}}},
"allowGeometryUpdates" : true,
"hasAttachments" : true,
"attachmentProperties" : [
{
"name" : "id",
"fieldName" : "ATTACHMENTID",
"isEnabled" : true
},
{
"name" : "globalId",
"fieldName" : "AttachmentGlobalID",
"isEnabled" : true
},
{
"name" : "name",
"fieldName" : "ATT_NAME",
"isEnabled" : true
},
{
"name" : "size",
"fieldName" : "DATA_SIZE",
"isEnabled" : true
},
{
"name" : "contentType",
"fieldName" : "CONTENT_TYPE",
"isEnabled" : true
},
{
"name" : "keywords",
"fieldName" : "Keywords",
"isEnabled" : true
},
{
"name" : "exifInfo",
"fieldName" : "ExifInfo",
"isEnabled" : true
}
],
"htmlPopupType" : "esriServerHTMLPopupTypeNone",
"hasM" : true,
"allowUpdateWithoutMValues" : true,
"hasZ" : false,
"objectIdField" : "OBJECTID",
"uniqueIdField" :
{
"name" : "OBJECTID",
"isSystemMaintained" : true
},
"globalIdField" : "",
"typeIdField" : "",
"fields" : [
{
"name" : "OBJECTID",
"type" : "esriFieldTypeOID",
"alias" : "OBJECTID",
"sqlType" : "sqlTypeOther",
"nullable" : false,
"editable" : false,
"visible" : true,
"domain" : null,
"defaultValue" : null
},
{
"name" : "Field1",
"type" : "esriFieldTypeString",
"alias" : "Field1",
"sqlType" : "sqlTypeOther",
"length" : 256,
"nullable" : true,
"editable" : true,
"visible" : true,
"domain" : null,
"defaultValue" : null
},
{
"name" : "Field2",
"type" : "esriFieldTypeString",
"alias" : "Field2",
"sqlType" : "sqlTypeOther",
"length" : 256,
"nullable" : true,
"editable" : true,
"visible" : true,
"domain" : null,
"defaultValue" : null
}
],
"indexes" : [
{
"name" : "Test_Point_Layer_TESTING_Shape_sidx",
"fields" : "Shape",
"isAscending" : false,
"isUnique" : false,
"description" : "Shape Index"
},
{
"name" : "PK__Test_Poi__F4B70D85571405E5",
"fields" : "OBJECTID",
"isAscending" : true,
"isUnique" : true,
"description" : "clustered, unique, primary key"
}
],
"dateFieldsTimeReference" : {
"timeZone" : "UTC",
"respectsDaylightSaving" : false
},
"preferredTimeReference" : null,
"types" : [],
"templates" : [
{
"name" : "New Feature",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"Field1" : null,
"Field2" : null
}
}
}
],
"supportedQueryFormats" : "JSON, geoJSON, PBF",
"supportedAppendFormats" : "sqlite,geoPackage,shapefile,filegdb,featureCollection,geojson,csv,excel,imageCollection",
"supportedExportFormats" : "csv,shapefile,sqlite,geoPackage,filegdb,featureCollection,geojson,excel",
"supportedSpatialRelationships" : [
"esriSpatialRelIntersects",
"esriSpatialRelContains",
"esriSpatialRelCrosses",
"esriSpatialRelEnvelopeIntersects",
"esriSpatialRelIndexIntersects",
"esriSpatialRelOverlaps",
"esriSpatialRelTouches",
"esriSpatialRelWithin",
"esriSpatialRelDisjoint",
"esriSpatialRelRelation"
],
"supportedContingentValuesFormats" : "JSON, PBF",
"supportedSyncDataOptions" : 4,
"hasStaticData" : false,
"maxRecordCount" : 2000,
"standardMaxRecordCount" : 32000,
"standardMaxRecordCountNoGeometry" : 32000,
"tileMaxRecordCount" : 8000,
"maxRecordCountFactor" : 1,
"capabilities" : "Create,Delete,Query,Update,Editing"
}
]
}
Add to your exsiting service layer. So here is a dummy one I set up:
Before

Add to Definition:

Remove the json already there and paste your edited json from above.

Paste in your edited json from above and you should see this response if successful:
