This file contains the code for the interview peoblem.
The code has features like:
- Reads data from a CSV file.
- Converts the CSV data into JSON format.
- Sends API requests with the following headers:
Authorization: Bearer TokenToken: Bearer <actual_token>payload
- request payloads based on CSV data.
- Validates API responses.
This code has total 5 functions:
- formated_time --> To convert date to ISO format
- read_csv --> To read data from csv file and generate json data.
- convert_to_json --> to write generated json data to a file.
- def API_Request_to_add_user --> to update the request attributes like url, token, headers, payload.
- sending_API_request --> this will send an http request and validates the API response and also displays the http status code.
End Result :
- I was able to convert the csv data to json data, that matches the given sample json format.
- and i have written function for sending an request with payload, token and headers.
Missing piece:
- I tried sending an request in postman to check the functionality, but http status code 401, mentioning "Unauthorized: Not allowed from your IP".
---- If you have a moment, could you go through my code to ensure everything is in line with the expectations? I'd love to hear any thoughts you have. ---- and also i would like to get confirmed that the API endpoint is correct and accessible.(Because i have received 401 status code)