Open APIs

 View Only
  • 1.  HTTP response code for list operations with search fields but no matching records

    TM Forum Member
    Posted Jan 27, 2022 10:40
    Hi,

    We're implementing several APIs that have list and search functions (geographic address for example) that allow the consumer to perform search operations - for example postcode=AB12CD. There is always the possibility that there are no matching records but the documentation doesn't specify as far as I can see what the expected HTTP response code is and there doesn't seem to be a consensus online after some searching either. In this scenario the response to the user should I think be just an empty array []

    The possible ones that could be used would seem to be

    1.  404 Not Found - I'm not in favour of this one as it implies something was wrong as it's an error code, but the server correctly accepted and processed the response. It just didn't find any matches for what you were looking for.
    2. 204 No Content - The definition of this says that it MUST NOT include a response body which to me rules it out as we have to return an empty array I believe
    3. 200 OK - This seems the best answer to me at the moment as the content tells you the request was processed but the length of the array says there were no matches (similar to a zero length result set from a database query).
    How have others implemented a list operation with criteria that returned no records?

    ------------------------------
    Steve Ranford-Bragg
    BT Group plc
    ------------------------------


  • 2.  RE: HTTP response code for list operations with search fields but no matching records

    TM Forum Member
    Posted Jan 27, 2022 15:12
    Hi Steve
    Please refer to a previous discussion on this same issue here.
    Bottom line is that it should be 200 - for some reason I cannot trace a JIRA issue that would cause the TMF630 guidelines to be updated to make this clear.
    Anyway hope it helps.

    ------------------------------
    Jonathan Goldberg
    Amdocs Management Limited
    Any opinions and statements made by me on this forum are purely personal, and do not necessarily reflect the position of the TM Forum or my employer.
    ------------------------------



  • 3.  RE: HTTP response code for list operations with search fields but no matching records

    TM Forum Member
    Posted Jan 28, 2022 04:16
    Thanks, good to see the opinion was the same as I had - I did try to look back for threads on the topic but I obviously need to improve my search skills :-)

    ------------------------------
    Steve Ranford-Bragg
    BT Group plc
    ------------------------------