How to retreive Key and Collection after using WriteStorageObjects API

So I have used both WriteStorageObjects and ReadStorageObjects in my unreal engine project and I am using Nakama Client 2.7.0. I want to assign Key and Value when I read which is working fine with the following code.

void UBackendGameinstance::OnReadStorageObjectsSuccess(const TArray& StorageObjects)
{
UE_LOG(LogTemp, Log, TEXT(“Read success:”));

for (auto& objects : StorageObjects) {
	FString key = objects.Key;
	FString value = objects.Value;
	UE_LOG(LogTemp, Warning, TEXT("Object key:%s  ,value:%s "), *key, *value);
	this->valReturn.Broadcast(key, value);
}

}

I want to implement the same for WriteStorageObjects but it is not working as expected it directly calls the OnError Delegate function.

void UBackendGameinstance::OnWriteStorageObjectsSuccess(const FNakamaStoreObjectAcks& acks)
{
UE_LOG(LogTemp, Log, TEXT(“Success writing storage objects”));

for (auto& ack : acks) {
	FString key = ack.key.c_str();
	FString collection = ack.collection.c_str();
	UE_LOG(LogTemp, Warning, TEXT("%s Has been updated in collection: %s"), *key, *collection);
}

}

My guess is as you can see in ReadObject it is TArray they use TArray but in WritingObject it is just “const FNakamaStoreObjectAcks&” So I am not sure whether I can loop through the values.

So I want to set the Key and Collection in OnWriteStorageObjectsSuccess. If you guys have any idea how to implement it. It will be very helpful for us.

Thanks in advance

Please ensure the API request code also here,

I have attached the API requested code here

void UBackendGameinstance::setToNakama(const FString key, const FString collection, const FString playerDataInJson)
{
FNakamaStoreObjectWrite WriteObject;
NStorageObjectWrite savesObject;
savesObject.collection = TCHAR_TO_UTF8(*collection);
savesObject.key = TCHAR_TO_UTF8(*key);
savesObject.value = TCHAR_TO_UTF8(*playerDataInJson);

if (key.IsEmpty() || collection.IsEmpty())
{
	UE_LOG(LogTemp, Error, TEXT("Invalid collection or key value supplied. They must be set."));
	return;
}

TArray<FNakamaStoreObjectWrite> StorageObjectsData = { WriteObject };

FOnStorageObjectAcks WriteStorageObjectsSuccessDelegate;
WriteStorageObjectsSuccessDelegate.AddDynamic(this, &UBackendGameinstance::OnWriteStorageObjectsSuccess);

FOnError WriteStorageObjectsErrorDelegate;
WriteStorageObjectsErrorDelegate.AddDynamic(this, &UBackendGameinstance::OnWriteStorageObjectsError);

client->WriteStorageObjects(session, StorageObjectsData, WriteStorageObjectsSuccessDelegate, WriteStorageObjectsErrorDelegate);

}

lot’s of things is different in new 2.7.0 sdk version
@tom will help, i think

We somwhow figured it out. I have attached the solution below check it out for future references

This is changes inside the API Function for WriteStorageObjects

FNakamaStoreObjectWrite WriteObject;
WriteObject.PermissionWrite = ENakamaStoragePermissionWrite::OWNER_WRITE;
WriteObject.PermissionRead = ENakamaStoragePermissionRead::OWNER_READ;
WriteObject.Collection = TCHAR_TO_UTF8(*collection);
WriteObject.Key = TCHAR_TO_UTF8(*key);
WriteObject.Value = TCHAR_TO_UTF8(*playerDataInJson);

This is OnSuccessDelegate Changes

void UBackendGameinstance::OnWriteStorageObjectsSuccess(const FNakamaStoreObjectAcks& acks)
{

for (auto& ack : acks.StorageObjects) {
	FString key = ack.Key;
	FString collection = ack.Collection;
	UE_LOG(LogTemp, Warning, TEXT("%s Has been updated in collection: %s"), *key, *collection);
}

UE_LOG(LogTemp, Log, TEXT("Success writing storage objects"));	

}