Skip to content
Ifrim Alexandra edited this page Sep 13, 2025 · 4 revisions

/update/ endpoint in QA

/update/ endpoint in SWAGGER-UI

curl -X 'PUT' \ 'http://peviitorqa.go.ro/api/v0/update/' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "job_title": "<string>", "company": "<string>", "city": "<string>", "job_link": "<string>" }'



Technical Documentation: Update Endpoint

Request and Response Structure

  • Method: PUT

  • Endpoint name: /update

  • Request Body Parameters:

    • job_title – Title of the job (required).
    • company – Company name (required).
    • city – City where the job is located (required).
    • job_link – URL to the job listing (required).
  • Response Format: application/json; charset=utf-8

Expected Data Format

Request Body

{
  "job_title": "<string>",
  "company": "<string>",
  "city": "<string>",
  "job_link": "<string>"
}

List of Status Codes and Error Messages

  • 200 OK – Request successful, returns list of companies and job counts if applicable.
  • 400 Bad Request – Invalid request parameters or missing required fields.
  • 401 Unauthorized – Authentication is required or invalid credentials.
  • 403 Forbidden – Access denied due to insufficient permissions.
  • 404 Not Found – The requested endpoint or resource does not exist.
  • 405 Method Not Allowed – Only PUT requests are supported.
  • 500 Internal Server Error – An unexpected error occurred on the server.
  • 502 Bad Gateway – The primary and fallback servers are both unreachable.
  • 503 Service Unavailable – The SOLR server is down or unreachable.
  • 507 Insufficient Storage – SOLR or API server runs out of space/memory.
{
    "error": "<message>",
    "code": "<number>"
}

Business Logic Applied

  • Validates the PUT method and handles preflight OPTIONS requests.
  • Normalizes city names to match SOLR records.
  • Sends JSON payload to SOLR’s /update endpoint with commitWithin=1000 and overwrite=true options.

Security Measures

  • CORS policy: Open to all (Access-Control-Allow-Origin: *).
  • Method Restriction: Only PUT requests allowed.

Dependencies

  • SOLR Search Server – Required to add job data.
  • PHP curl and stream_context_create – Used to communicate with SOLR API.

Known Limitations & Edge Cases

  • SOLR Downtime: Returns 503 if SOLR is unavailable.
  • Missing or Invalid Fields: Returns 400 if any required field is missing or invalid.
  • Non-empty string: All fields must be non-empty.
  • Security Risks: No authentication currently implemented.
  • To do: Add API keys.
  • To do: Log errors for easier debugging.
  • To do: Implement security.json and IP whitelisting.


Business Requirement Document: Add Job Listings Endpoint

Objective:

The objective of this project is to develop an API endpoint that adds job listings in a SOLR index. This endpoint will be used to manage job data efficiently by updating existing job listings.

Key Requirements:

  1. Functionality:

    • The endpoint should accept job details such as job title, company, city, and job link as input.
    • It should add the corresponding job listing in the SOLR index.
    • The endpoint should support normalization of city names to ensure consistency.
  2. Error Handling:

    • The endpoint should handle errors gracefully, providing meaningful error messages to users.
    • Specific error handling should include scenarios where required parameters are missing or the add operation fails.
  3. User Experience:

    • The endpoint should respond quickly to ensure a seamless user experience.
    • The response should include a clear success message or error details.
  4. Data Integrity:

    • Ensure that the added job data is accurate and consistent.
    • The endpoint should only add data for the specified job listing.
  5. Security:

    • Implement appropriate security measures to protect user data and prevent unauthorized access to the SOLR index.
  6. Scalability:

    • The endpoint should be designed to handle a high volume of requests without impacting performance.

Acceptance Criteria:

  • The endpoint successfully adds job listings in the SOLR index.
  • The endpoint returns a clear success message or error details.
  • Error messages are clear and informative for users.
  • The endpoint responds within an acceptable time frame.

Assumptions and Dependencies:

  • The SOLR index is properly configured and populated with job data.
  • Necessary infrastructure and resources are available to support the endpoint.

Risks and Mitigation Strategies:

  • Risk: Technical issues with the SOLR index could prevent job adds.

    • Mitigation: Regularly monitor the SOLR index for errors and perform maintenance as needed.
  • Risk: High traffic could impact performance.

    • Mitigation: Implement load balancing and optimize server resources to handle increased traffic.
  • Risk: Unauthorized access could lead to data breaches.

    • Mitigation: Implement robust security measures, including authentication and authorization checks.

Clone this wiki locally