OPTIONS return 204, POST return 200 but data is not entered in db - json

I am using jsonplaceholder (http://jsonplaceholder.typicode.com/) locally. I am testing my GET and POST calls via extjs rest proxy.
I am able to read data. But when I create a model object and save it, the HTTp code for option is 204 and for POST is 200
BUT data is not stored in database of jsonplaceholder local server.
Any Idea where actual problem exists?

I have worked with json-server and this is the expected results and for your knowledge, here is a detailed explanation of HTTP Status codes Status Code Definitions.

Related

API POST response returning 400 response code in Jmeter

I am trying to create a test plan using jmeter.its for an API Post request, I have a header manager, bodydata, checked for spellings and the syntax seems to be correct. However, Im getting 400 response code with the following error shown in the attached image. Anyone with an idea how I can resolve this? Thank you. the error
Here is the request the request
The user doesn't have to be logged in, i have added a header manager, I have also noticed there header has a cookie value thats hard coded but it appears to be the same in every request. In the UI the API request returns 200 and thats what im expecting with the Jmeter script.
In its current form the question cannot be answered comprehensively.
HTTP Status Code 400 means that
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
Check that your ${site} and ${csVersion} variables have their respective values using Debug Sampler and View Results Tree listener combination
Cross check headers sent by JMeter and by the "UI", the most important is Content-Type
Use a sniffer tool like Wireshark of Fiddler and capture the requests which are being sent by JMeter and the "UI", the requests must be exactly the same apart from dynamic parameters which need to be correlated
The issues was being caused by an anti-forgery cookie which was hard coded in the request.I used a regex to extract the value from a previous request and used a variable value from the regex to make sure the same value is being passed on to the request that was failing.

How to listen for an api update in Python / Flask

I've managed to connect to an api and request data account_balance but how can I keep the connection open to listen to that particular api address to be notified when it is updated, i.e. in this case when a transaction occurs?
import requests
json = { "action": "account_balance","account": "nano_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3" }
test = requests.post("https://nanoverse.io/api/node",json=json).json()
print(test)
So far I've tried using flask-socketio but none of the examples seem to do what I'm specifically asking for.
The code above is sending an account balance via HTTP post to some server. I assume that the server at the URL is the Flask server you are talking about. Here is a great tutorial on how to get started with Flask, including how to parse requests: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04. What you want to do is set up a route for /api/node and that Python method will be called each time that URL receives a POST. Put your logic for analyzing transactions in there and you're all set.

Caching API response from simple ruby script

I'm working on a simple ruby script with cli that will allow me to browse certain statistics inside the terminal.
I'm using API from the following website: https://worldcup.sfg.io/matches
require 'httparty'
url = "https://worldcup.sfg.io/matches"
response = HTTParty.get(url)
I have to goals in mind. First is to somehow save the JSON response (I'm not using a database) so I can avoid unnecessary requests. Second is to check if the new data is available, and if it is, to override the previously saved response.
What's the best way to go about this?
... with cli ...
So caching in memory is likely not available to you. In this case you can save the response to a file on disk.
Second is to check if the new data is available, and if it is, to override the previously saved response.
The thing is, how can you check if new data is available without doing a request for the data? Not possible (given the information you provided). So you can simply keep fetching data every 5 minutes or so and updating your local file.

iTunes Store Customer Reviews API XML Endpoint Broken

I used to use the XML endpoint because it provided review dates for each review called 'updated'. This is not contained in the JSON endpoint. However, the XML endpoint stopped working. I get the error seen below:
Web Server Error
Description: The host did not return the document correctly.
Has anyone experienced the same issue? Any workarounds? Do you anticipate this will ever be fixed by Apple? Do you think the JSON endpoint might be taken down any time soon?
XML Endpoint (Broken)
https://itunes.apple.com/us/rss/customerreviews/id=1145275343/mostrecent/xml
JSON Endpoint (Working)
https://itunes.apple.com/us/rss/customerreviews/id=1145275343/mostrecent/json
It appears the XML endpoint is up and running again. No more Web Server Error. Hopefully the endpoint stays up.

JMeter: failed POST method (JSON body and filtering in path)

I'm trying (without success) to create data in JMeter (POST method) using JSON body data and only one way of access through API: access key (no login credentials or other details for server).
The access key only works in PATH (tried in header, no luck) and besides that, filters are required in path to call the exact services I need (please see screenshot 1)
Here are a couple of screenshots (data was edited, sensitive info)
1
HTTP Request
2
Header Manager
In Results Tree I get 301 Moved Permanently.
Is there a way to add those filters, keep the JSON body data + access token in path and get a 200/201 Created? :)
Found the issue for "301 Moved Permanently" after Post method was used:
Should have specified in Protocol "https" not http :(