Aymeric Pellan
Aymeric Pellan

Reputation: 1

Agora Cloud Recording - 500 Error with Code 2 - Post Method API Body Check Failed

I'm encountering an issue while implementing Agora Cloud Recording. When I attempt to start the cloud recording, I receive the following error:

POST https://api.agora.io/v1/apps/{appID}/cloud_recording/resourceid/{resourceID}/mode/mix/start Error response data: { "code": 2, "reason": "post method api body check failed!" } Error: Request failed with status code 500

The error code 2 with the reason "post method api body check failed!" suggests something might be wrong with the request body or parameters.

Details:

I'm using Agora's Cloud Recording API in mix mode. I've successfully acquired the resourceID, but the error occurs when calling the /start API to initiate the recording. I'm following Agora's documentation, but something seems to be going wrong with the body of the POST request.

My Current Request Body:

{
  "cname": "myChannelName",
  "uid": "0",
  "clientRequest": {
    "token": "007eJxTYFi+...",
    "recordingConfig": {
      "maxIdleTime": 30,
      "streamTypes": 2,
      "channelType": 1,
      "videoStreamType": 0,
      "transcodingConfig": {
        "height": 640,
        "width": 360,
        "bitrate": 500,
        "fps": 15,
        "mixedVideoLayout": 1
      }
    },
    "recordingFileConfig": {
      "avFileType": ["hls", "mp4"]
    },
    "storageConfig": {
      "vendor": 1,
      "region": 0,
      "bucket": "my-agora-bucket",
      "accessKey": "my-access-key",
      "secretKey": "my-secret-key"
    }
  }
}

IAM Policy for AWS S3 Bucket:

Here's the IAM policy I have added to grant Agora access to the AWS S3 bucket:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation",
                "s3:ListBucketMultipartUploads"
            ],
            "Resource": [
                "arn:aws:s3:::agora-recordings-bucket"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:AbortMultipartUpload",
                "s3:ListMultipartUploadParts"
            ],
            "Resource": [
                "arn:aws:s3:::agora-recordings-bucket/*"
            ]
        }
    ]
}

Resource Acquisition works fine, and I'm getting a valid resourceID. I generated a token for recording with the PUBLISHER role and verified it. I've double-checked the bucket, accessKey, and secretKey for my cloud storage (AWS S3). The vendor is set to 1 for AWS, and region is set to 0. I've tried setting the uid to "0" in both string and integer format to match the token generation process. The transcodingConfig seems valid, as per the Agora documentation, but the error persists.

Questions:

What could be causing the POST method API body check to fail? Is there something specific in the body format, such as encoding, or a required field that might be missing or incorrectly formatted? Are there any known issues with Agora's API or common mistakes that could trigger the code 2 error?

Any guidance or suggestions would be greatly appreciated!

Additional Information:

Platform: Node.js (Axios used for requests) Agora Version: Cloud Recording RESTful API v1 Error Response: 500 Internal Server Error, with code 2.

Upvotes: 0

Views: 57

Answers (0)

Related Questions