Issue with Effect HttpClient Request for WhatsApp Cloud API Media Download

Hi guys! I have a question about the Http client, I am using the whatsapp cloud api to download media from the endpoint and for some reason the endpoint works in postman but when I try and do it in effect it doesn't work.

this is successful curl request from postman

curl --location 'https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=xxx&ext=xxx&hash=xxx' \
--header 'Authorization: Bearer xxx'


but when I try and do it in effect it doesn't work
...
    const httpClient = (yield* HttpClient.HttpClient).pipe(
      HttpClient.filterStatusOk
    );

    yield* Effect.log(
      `Downloading media from Cloud API: ${payload.cloudApiMediaId}`
    );
    const media = yield* meta.downloadCloudApiMedia({
      apiKeyHash: payload.apiKeyHash,
      mediaId: payload.cloudApiMediaId,
    });

    yield* Effect.log(`Successfully retrieved media with URL: ${media.url}`);

    // it fails here at the download with a 400 error
    const req = HttpClientRequest.get(media.url).pipe(
      HttpClientRequest.bearerToken(payload.apiKeyHash),
      HttpClientRequest.accept("*/*")
    );
    const response = yield* httpClient.execute(req).pipe(
      Effect.retry({
        times: 3,
        schedule: Schedule.exponential("1.5 seconds", 1.5),
      })
    );


I've also tried to log the request out and this is the result
    {
      "_id": "@effect/platform/HttpClientRequest",
      "url": "https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=xxx&hash=xxx",
      "method": "GET",
      "body": {
        "_id": "@effect/platform/HttpBody",
        "_tag": "Empty"
      },
      "hash": {
        "_id": "Option",
        "_tag": "None"
      },
      "headers": {
        "accept": "*/*",
        "authorization": "Bearer xxx"
      }
    }
Was this page helpful?