ld.news.get_headlines

Hi DevPortal, good afternoon. May I ask for your help.

I use python library to fetch news by ld.news.get_headlines('Elon musk', count=10), while it return error: LDError: Error code 400 | Query cannot return any result. Is there any format for query in this function?

Kindly pls provide me a sample script on how to do this as well in codebook.

Thank you.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @RALPHPAOLO.NAVARRO

    Thank you for reaching out to us.

    Please try this one:

    ld.news.get_headlines("'Elon musk'", count=10)
    
    image.png
  • @Jirapongse Thank you. was able to share it with the client. :)

  • @Jirapongse please help with client followup :

    Thank you for your help. I would also like to know if I were to filter the headlines to be 'X' (formerly known as twitter), am I suppose to use this: 

    ld.news.get_headlines("'Elon musk' AND Source:'X'", count=10)? It seems like it returns nothing back, could you check whether this is the correct code?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Please check this discussion.

  • Hello @Jirapongse
    We kindly request to look into the below follow-up at the earliest as soon as possible.

    Follow-up:

    Thank you for your help. I would also like to know if I were to filter the headlines to be 'X' (formerly known as twitter), am I suppose to use this: 

    ld.news.get_headlines("'Elon musk' AND Source:'X'", count=10)? It seems like it returns nothing back, could you check whether this is the correct code?

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Shivanand_123

    According to my finding, it is not a coding issue.

    The problem is in the http://localhost:9001/api/rdp/data/news/v1/headlines endpoint in Workspace.

    [2025-09-18T13:11:44.856214+07:00] - [sessions.desktop.workspace.0] - [DEBUG] - [36184 - MainThread] - [http_service] - [build_request] - HTTP Request id 3
    url = http://localhost:9001/api/rdp/data/news/v1/headlines?query=%27Elon+musk%27+AND+SOURCE%3AX&limit=10&sort=newToOld
    method = GET
    headers = {'request-timeout': '16000', 'x-tr-applicationid': 'LD-PYTHON-LIB', 'Authorization': 'Bearer <token>'}
    [2025-09-18T13:11:47.114397+07:00] - [sessions.desktop.workspace.0] - [DEBUG] - [36184 - MainThread] - [http_service] - [request] - HTTP Response id 3 Headers(…)
    status_code = 400
    text = {"error":{"id":"7a9baf6c-d8ce-4d53-acdb-6fbabfd37a8d","code":31,"message":"Query cannot return any result."}}

    You need to contact the Workspace support team to verify what the problem is.

  • Hello @Jirapongse
    Thank you.
    We are from Workspace IWS(AIMS) support team.
    We kindly request to kindly let us know the specific support team we can contact regarding the issue please.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Shivanand_123

    Sorry. I don't know about the Workspace escalation path.

    Please escalate to the team that maintains this /api/rdp/data/news/v1/headlines endpoint.