I have been trying to extract the image url from twitter api’s search tweets with Id response. The url are present in the Json response from the api in the includes->media array in the response. But when I try to get it using the twitter java Sdk it is not present their. Following is the link to the Sdk:
Twiiter Java sdk
Twitter api request

(https://api.twitter.com/2/tweets?ids=1102112466283175936,1553802769207037953,1552279853633835009&tweet.fields=author_id,entities,attachments,conversation_id,created_at,referenced_tweets&expansions=attachments.media_keys&media.fields=url,type)

JSON Response

{
"data": [
    {
        "text": "5000 selfies make up this iconic image of @jeremycorbyn in today's @ObserverUK, calling on him to bring courage and leadership to unite @UKLabour MPs behind a #PublicVote on #Brexit. RT to support! ",
        "attachments": {
            "media_keys": [
                "3_1102112450588147712"
            ]
        },
        "entities": {
            "hashtags": [
                {
                    "start": 159,
                    "end": 170,
                    "tag": "PublicVote"
                },
                {
                    "start": 174,
                    "end": 181,
                    "tag": "Brexit"
                }
            ],
            "urls": [
                {
                    "start": 198,
                    "end": 221,
                    
                    "expanded_url": "https://twitter.com/Avaaz/status/1102112466283175936/photo/1",
                    "display_url": "pic.twitter.com/RAQN3rvXOc",
                    "media_key": "3_1102112450588147712"
                }
            ],
            "mentions": [
                {
                    "start": 42,
                    "end": 55,
                    "username": "jeremycorbyn",
                    "id": "117777690"
                },
                {
                    "start": 67,
                    "end": 78,
                    "username": "ObserverUK",
                    "id": "1017383741919023104"
                },
                {
                    "start": 136,
                    "end": 145,
                    "username": "UKLabour",
                    "id": "14291684"
                }
            ]
        },
        "id": "1102112466283175936",
        "created_at": "2019-03-03T07:44:22.000Z",
        "conversation_id": "1102112466283175936",
        "author_id": "2553151"
    },
    {
        "text": "@oldschoolmonk My current favorite doge meme 😂❤️ ",
        "attachments": {
            "media_keys": [
                "3_1553802763171414016"
            ]
        },
        "id": "1553802769207037953",
        "created_at": "2022-07-31T18:00:23.000Z",
        "conversation_id": "1553801521476669440",
        "referenced_tweets": [
            {
                "type": "replied_to",
                "id": "1553801521476669440"
            }
        ],
        "entities": {
            "urls": [
                {
                    "start": 49,
                    "end": 72,
                    
                    "expanded_url": "https://twitter.com/Pareshaan_aatma/status/1553802769207037953/photo/1",
                    "display_url": "pic.twitter.com/Gp8FBBHmHO",
                    "media_key": "3_1553802763171414016"
                }
            ],
            "mentions": [
                {
                    "start": 0,
                    "end": 14,
                    "username": "oldschoolmonk",
                    "id": "135241813"
                }
            ]
        },
        "author_id": "224239908"
    },
    {
        "text": "I've just found out that 3 of my Samsung phones' batteries have blown up because of the recent UK heatwave \n\nNot a single other brand has 🤔 ",
        "attachments": {
            "media_keys": [
                "3_1552279848432844800",
                "3_1552279848416169987"
            ]
        },
        "id": "1552279853633835009",
        "created_at": "2022-07-27T13:08:51.000Z",
        "entities": {
            "annotations": [
                {
                    "start": 33,
                    "end": 39,
                    "probability": 0.8414,
                    "type": "Product",
                    "normalized_text": "Samsung"
                },
                {
                    "start": 95,
                    "end": 96,
                    "probability": 0.5409,
                    "type": "Place",
                    "normalized_text": "UK"
                }
            ],
            "urls": [
                {
                    "start": 140,
                    "end": 163,
                    
                    "expanded_url": "https://twitter.com/Mrwhosetheboss/status/1552279853633835009/photo/1",
                    "display_url": "pic.twitter.com/LI6Qrz8xSv",
                    "media_key": "3_1552279848432844800"
                },
                {
                    "start": 140,
                    "end": 163,
                    
                    "expanded_url": "https://twitter.com/Mrwhosetheboss/status/1552279853633835009/photo/1",
                    "display_url": "pic.twitter.com/LI6Qrz8xSv",
                    "media_key": "3_1552279848416169987"
                }
            ]
        },
        "conversation_id": "1552279853633835009",
        "author_id": "3363946175"
    }
],
"includes": {
    "media": [
        {
            "media_key": "3_1102112450588147712",
            "type": "photo",
            "url": "https://pbs.twimg.com/media/D0t9bz_XgAAl3hD.jpg"
        },
        {
            "media_key": "3_1553802763171414016",
            "type": "photo",
            "url": "https://pbs.twimg.com/media/FZA3YXXaQAAOnma.jpg"
        },
        {
            "media_key": "3_1552279848432844800",
            "type": "photo",
            "url": "https://pbs.twimg.com/media/FYrOTD3WQAA0tvt.jpg"
        },
        {
            "media_key": "3_1552279848416169987",
            "type": "photo",
            "url": "https://pbs.twimg.com/media/FYrOTDzX0AMBSnE.jpg"
        }
    ]
}
}

What exact code / library are you using? If the json has the information, it should also be possible to get it as a Java object, but this depends entirely on how the library was made, and how it implemented that part.