SonataUserBundle Api Response returns empty JSON - json

I'm trying to get the JSON response of SonataUserBundle Api.
So after following the config process from the Sonata HomePage docs
It looks like this API returns an empty object

It looks like you forgot to add metadata directory to jms_serializer config.
jms_serializer:
metadata:
directories:
SonataDatagridBundle:
namespace_prefix: 'Sonata\DatagridBundle\'
path: '#SonataDatagridBundle/Resources/config/serializer'
# Also don't forget to add NewsBundle metadata too
ApplicationSonataNewsBundle:
namespace_prefix: 'Application\Sonata\NewsBundle\'
path: '#ApplicationSonataNewsBundle/Resources/config/serializer'

user class have private members duw to which it can not be accessed. either you need you change it specifier or you can iterate it and store in an array and than you can pass it

Related

Create blog with Static json file with Fetch in Nuxt. How to use slug to get content of specific node?

Am trying to build a blog with a static json file in Nuxt(with http module).
Using the Nuxt 'Mountains' example as a base, for testing. I saved the api response as json in the 'static' folder.
(Example is here: https://nuxtjs.org/examples/data-fetching-fetch-hook)
Using 'fetch' to connect to the json in static folder on the Blog-page is working.
See: https://3udju.sse.codesandbox.io/blog
Have problems with using Fetch to identify the individual node/content.
See: https://3udju.sse.codesandbox.io/blog/mount-everest (No content here)
I have no idea how to recreate this - with the local Json file instead of the Api url:
https://api.nuxtjs.dev/mountains/${this.$route.params.slug}
And the _slug.vue file:
https://codesandbox.io/s/nuxt-http-fetch-static-json-3udju?file=/pages/blog/_slug.vue
Have tried to use a Filter on the Fetch. Have tried different querystrings as parameters on the .json, but its not working.
Have searched for :
get data from json slug id
get object based on slug in local json
fetch local json filter on slug
Watched several youtubes about Fetch but haven't found anything.
If anyone has a clue or can point me towards an solution, much appreciated.
Found a way to use a static json in the Content module in Nuxt. Example here:
https://codesandbox.io/s/nuxt-http-fetch-static-json-3udju?file=/pages/cars/index.vue
Also see 'cars.json' in 'Content' folder.
Frontend : https://3udju.sse.codesandbox.io/cars (reused the mountains as cars ;-)

Defining a type in the routes file

I want to be able to send a JSON to a method on my controller and parse that to an object but to be able to do that I have to define the method on my "routes" file as well.
POST /retornaParametros
controllers.HomeController.retornaParametros(parametro:Dog)
I thought this would work but it doesn't. How do i tell my routes file to accept the Dog object
You should be using Query binder
Refer https://www.playframework.com/documentation/2.6.x/ScalaRequestBinders#querystringbindable

JMETER store request JSON Element as variable

Trying to figure out how I can access elements of a post request body (JSON) and store it as a variable. One of my tests creates a user using ${__UUID}#gmail.com - and I'd like to then check that my response includes this same information.
I'm guessing I could probably create the UUID before the request and store it as a variable, and then check against that, but wondering if there is anything similar to JSON Path Extractor for request elements.
There is a JSR223 PreProcessor you can use to fulfil your requirement.
Assuming you have JSON Payload like:
{
"user": "${__UUID}#gmail.com"
}
Add JSR223 PostProcessor and put the following code into "Script" area:
def user = com.jayway.jsonpath.JsonPath.read(sampler.getArguments().getArgument(0).getValue(), '$..user').get(0).toString()
log.info('Random user email:' + user)
vars.put('user', user)
The above code will:
Extract from the request everything which matches $..user JSON Path expression
Print it to jmeter.log file
Store the value into a JMeter Variable so you will be able to refer it as ${user} where required.
More information:
Apache Groovy - Why and How You Should Use It
Groovy - Parsing and Producing JSON

How do I invoke multiple http requests dynamically in jmeter

I have fetched multiple paths of multiple urls from the JSON response using JSON Path extractor in jmeter. The paths are stored in the jmeter variables like url_0,url_1, url_2 and so on. The server IP address is constant.
These urls fetched from the JSON response have to be invoked after parsing the JSON response as stated earlier. How do I achieve this particular behaviour in jmeter?
Use ForEach Controller as it described in Using Regular Expressions in JMeter
If you have variables like:
url_0=/some/path
url_1=/some/other/path
url_2=/some/another/path
etc.
Configure ForEach Controller as follows:
Input Variable Prefix: url
Start index for loop: -1
Output variable name: path
Add "_" before number: check
And use ${path} variable in underlying HTTP Request sampler

Receive JSON post

I am using $routeProvider to set a route like
when('/grab/:param1/:param2', {
controller: 'someController',
templateUrl: "templates/someTemplate.html",
}).
Then in the someController I can read the parameters with $routeParams.param1.
How can I receive a JSON POST instead so I donĀ“t have to use params in the URL ?
Is there something I can use in the controller e.g $request.postData ?
EDIT: I'll try to make it more clear
Instead of receiving param1 and param2 (that are in the URL of a GET call) and then use $routeParams to read them and use them in my controller, I would like to receive a JSON object (which of course stays in a POST request) and have that object available in my controller.
I finally got the problem. There is no PHP or whatever server side script on mywebsite.com that can get the JSON object (POST) and JavaScript by it self cannot as well. See also this.
You probably want to pass a service to the resolve option of the route in the route provider. The service should implement $http and fetch the json. A resolve option must complete the fetch before the controller initializes. The resolve will also make the json data available in the $scope of the controller.
Setting this up the first time is not trivial, but it is repeatable and also one of the most common ways to pass data from an http request to an Angular controller.
Take a look at this answer: AngularJS: factory $http.get JSON file