Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caption are no longer supported #10

Open
Kan-A-Pesh opened this issue Nov 1, 2023 · 7 comments
Open

Caption are no longer supported #10

Kan-A-Pesh opened this issue Nov 1, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@Kan-A-Pesh
Copy link

When I make the api call to post/upload/data endpoint I get a 400 error.
And when I try making the api call directly to the BeReal API, I get the same error with the following body:

{
    "error": "Bad Request",
    "statusCode": 400,
    "message": "Bad Request",
    "errorKey": "bad-request",
    "data": null,
    "fields": [
        "caption"
    ],
    "timestamp": "2023-11-01T12:04:10.248Z",
    "requestId": "62...af0"
}

I tried again without the caption property (directly with the BeReal API) and it works.
So the captions have probably been moved to another endpoint.

@chemokita13
Copy link
Owner

I will work on it!

@AaditT
Copy link
Contributor

AaditT commented Dec 16, 2023

@Kan-A-Pesh @chemokita13 can you explain how to successfully call the /post/upload/data endpoint?

I am calling with this body:

{
  "postData": {
    "resize": true,
    "late": true,
    "visibility": "friends",
    "retakes": 500,
    "taken_at": "2023-12-01T10:06:22.248Z",
    "location": "1,1"
  },
  "tokenData":  <JWT TOKEN from /login/verify>
}

and am getting the following response:

{
  "status": 500,
  "message": "Internal server error",
  "data": {
    "response": {
      "status": 400,
      "message": "Token not generated",
      "data": {
        "name": "JsonWebTokenError",
        "message": "jwt must be provided"
      }
    },
    "status": 400,
    "message": "Token not generated",
    "name": "HttpException"
  }
}

@Kan-A-Pesh
Copy link
Author

You need to use the postDataToken generated by the /post/upload/getData endpoint

To post you first need to get three tokens (front photo, back photo and post) with /post/upload/getData endpoint by adding your JWT token generated from /login/verify in the request body
Tokens are returned with the following format:

{
  "status": 201,
  "message": "Photo created",
  "data": {
    "firstPhotoToken": "tokentokentokentoken",
    "secondPhotoToken": "tokentokentokentoken",
    "postDataToken": "tokentokentokentoken"
  }
}

Then post your photos with the /post/upload/photo endpoint by adding the JWT corresponding to the front (firstPhotoToken) or back (secondPhotoToken) photo

After posting the two photos you can call /post/upload/getData with the third JWT token (postDataToken) and your BeReal should be posted!

@AaditT
Copy link
Contributor

AaditT commented Dec 17, 2023

You need to use the postDataToken generated by the /post/upload/getData endpoint

To post you first need to get three tokens (front photo, back photo and post) with /post/upload/getData endpoint by adding your JWT token generated from /login/verify in the request body Tokens are returned with the following format:

{
  "status": 201,
  "message": "Photo created",
  "data": {
    "firstPhotoToken": "tokentokentokentoken",
    "secondPhotoToken": "tokentokentokentoken",
    "postDataToken": "tokentokentokentoken"
  }
}

Then post your photos with the /post/upload/photo endpoint by adding the JWT corresponding to the front (firstPhotoToken) or back (secondPhotoToken) photo

After posting the two photos you can call /post/upload/getData with the third JWT token (postDataToken) and your BeReal should be posted!

@Kan-A-Pesh Hi, before I was not posting both my front photo and back photos, but am now doing it. To recap, I am able to (1) get my three tokens from /post/upload/getData (2) post both my front and back photos using the respective jwt token with /post/upload/photo. However, on step (3) I am using the postDataToken JWT token and am still getting the following 500.

{
  "status": 500,
  "message": "Internal server error",
  "data": {
    "response": {
      "status": 400,
      "message": "Token not generated",
      "data": {
        "name": "JsonWebTokenError",
        "message": "jwt must be provided"
      }
    },
    "status": 400,
    "message": "Token not generated",
    "name": "HttpException"
  }
}

Is there a potential issue with my request:

curl -X 'POST' \
  'https://berealapi.fly.dev/post/upload/data' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "postData": {
    "resize": false,
    "late": true,
    "visibility": "friends",
    "retakes": 0,
    "taken_at": "2023-12-01T10:06:22.248Z",
    "location": "[1,1]"
  },
  "tokenData": "postDataToken JWT"
}'

@chemokita13 chemokita13 added the bug Something isn't working label Dec 17, 2023
@chemokita13
Copy link
Owner

You need to use the postDataToken generated by the /post/upload/getData endpoint
To post you first need to get three tokens (front photo, back photo and post) with /post/upload/getData endpoint by adding your JWT token generated from /login/verify in the request body Tokens are returned with the following format:

{
  "status": 201,
  "message": "Photo created",
  "data": {
    "firstPhotoToken": "tokentokentokentoken",
    "secondPhotoToken": "tokentokentokentoken",
    "postDataToken": "tokentokentokentoken"
  }
}

Then post your photos with the /post/upload/photo endpoint by adding the JWT corresponding to the front (firstPhotoToken) or back (secondPhotoToken) photo
After posting the two photos you can call /post/upload/getData with the third JWT token (postDataToken) and your BeReal should be posted!

@Kan-A-Pesh Hi, before I was not posting both my front photo and back photos, but am now doing it. To recap, I am able to (1) get my three tokens from /post/upload/getData (2) post both my front and back photos using the respective jwt token with /post/upload/photo. However, on step (3) I am using the postDataToken JWT token and am still getting the following 500.

{
  "status": 500,
  "message": "Internal server error",
  "data": {
    "response": {
      "status": 400,
      "message": "Token not generated",
      "data": {
        "name": "JsonWebTokenError",
        "message": "jwt must be provided"
      }
    },
    "status": 400,
    "message": "Token not generated",
    "name": "HttpException"
  }
}

Is there a potential issue with my request:

curl -X 'POST' \
  'https://berealapi.fly.dev/post/upload/data' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "postData": {
    "resize": false,
    "late": true,
    "visibility": "friends",
    "retakes": 0,
    "taken_at": "2023-12-01T10:06:22.248Z",
    "location": "[1,1]"
  },
  "tokenData": "postDataToken JWT"
}'

Hey! @AaditT Are you sending also the login token in headers? I think isnt delcared in api docs but is necessary. I let you an example in typescript and axios

     const postDataToSend: { tokenData: string; postData: PostData } = {
                tokenData: postDataToken,
                postData: postData,
            };
            const responseOptions = await axiosInstance.post(
                "/post/upload/data",
                postDataToSend,
                {
                    headers: {
                        token: token,
                    },
                }
            );

@AaditT
Copy link
Contributor

AaditT commented Dec 18, 2023

Hi @chemokita13
I now tried using tthe login toker in header as such:

curl -X 'POST' \
  'https://berealapi.fly.dev/post/upload/data' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'token: <JWT from /login/verify>' \
  -d '{
    "postData": {
      "resize": false,
      "late": true,
      "visibility": "friends",
      "retakes": 0,
      "taken_at": "2023-12-18T10:06:22.248Z",
      "location": "[1,1]"
    },
    "tokenData": "<JWT postDataToken from /post/upload/getData>"
  }'

but am still getting the same internal server error

@chemokita13
Copy link
Owner

Hi @chemokita13 I now tried using tthe login toker in header as such:

curl -X 'POST' \
  'https://berealapi.fly.dev/post/upload/data' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'token: <JWT from /login/verify>' \
  -d '{
    "postData": {
      "resize": false,
      "late": true,
      "visibility": "friends",
      "retakes": 0,
      "taken_at": "2023-12-18T10:06:22.248Z",
      "location": "[1,1]"
    },
    "tokenData": "<JWT postDataToken from /post/upload/getData>"
  }'

but am still getting the same internal server error

Idk, it seems an error with maybe the "taken_at" param that is harder to implement, let me research it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants