Can't add headers to POST - jxbrowser

I have a trouble with JxBrowser. I just want to send a POST request with MY headers. And I can't do it.
browser.loadURL(new LoadURLParams("MY_URL","MY_DATA", "MY_HEADERS_HERE"));
What i'm doing wrong?

You should use specific format for your headers.
Please take a look at the following article for more details: https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013103-loading-url-with-post

Related

WP Rest API, when using _embed JSON errors

When I fetch data from this endpoint http://blog.local/wp-json/wp/v2/posts?page=1 I get a JSON object.
When I add the _embed param,http://blog.local/wp-json/wp/v2/posts?page=1&_embed, I get an image, no JSON.
According to the Wordpress documentation, when you pass the _embed parameter, you are supposed to get extra usefull data included in the response - here
I just get an actual JPG image returned.
Has anyone seen this before or know what the problem could be? I have to resort to adding custom endpoint to just get extra data back.
Okay so it turns out that a plugin I'm using to create fake posts (FakePress) for testing was causing the issue. Don't know how but disabling fixes the problem.

Symfony 4 - Send POST request with multipart/form-data

I want to send a POST request to register my users, but I don't want to type my login and password in the URL, like this. I wanted to use the multipart/form-data format, to send my arguments as if they were in a form, like that.
Do you know how can I do that?
Thanks in advance! ^^
If you want to make a POST request to some URL with some data, I suggest encoding the data in json format.
See json_encode or Symfony serializer or jms_serializer.
Or, if you wish, you can send url encoded data, using http_build_query.
Just remember to send the right Content-type header, application/json or application/x-www-form-urlencoded.
And to perform the request, consider using Guzzle or cURL.
I realize I've just provided you with official docummmentation about related stuff, but I haven't fully understood your question, so I tried giving you general pointers for you to research. There are good examples of certain functionallities I believe you will need in order to do this.
Assuming you have the URL to make the request:
gather the data to post
serialize the gathered data
execute the request to the url with the serialized data
parse the response body
continue doing your logic
In case this isn't what you were looking for, please provide some more context, some code you have (don't share any sensitive data), or something, so you could get more precise answers. I hope I've managed to help. Feel free to ask more questions.
Okay I used $request->request->get() to extract my values , like this :
$entityManager = $this->getDoctrine()->getManager();
$user = new User();
$user->setLogin($request->request->get('login'));
$user->setPassword($request->request->get('password'));
$entityManager->persist($user);
$entityManager->flush();
And then I serialize my values in a JSON object, it's working perfectly ^^ Thanks for your help! ^^

Syntax for POST request

I am trying to make a POST request to the following url: http://xxx.xxx.xxx.xxx/api/signup
However I get this response:
http://xxx.xxx.xxx.xxx/api/signup?first_name=&last_name=&email_id=&password=&dob ...Please pass parameters...
So I tried making the request like this:
http://xxx.xxx.xxx.xxx/api/signup?first_name=Jay&last_name=Last&email_id=Jay#test.com&password=qqq&dob=1/1/15
But I get the same response.
I have no idea what the correct syntax is supposed to be...
Can someone please explain how I should rewrite the url?
Edit
After I make the request, if successful, I get a response saying "success new user" and a JSON with the key/vals
Does encoding your values make any difference?
for example:
http://xxx.xxx.xxx.xxx/api/signup?first_name=Jay&last_name=Last&email_id=Jay%40test.com&password=qqq&dob=1%2F1%2F15

Is it possible to use nested resource in case of POST?

I use Play Framework 2.2.X.
Is it possible to map this route?:
POST /api/constructors/:constructorId/cars CarCrudController.create(constructorId)
I get a BadRequest (code 400) when hitting this route.
IMO, it seems that Play allows nested resources only for reads: GET instead of POST.
Is it possible?
Nested routes are supported in any HTTP method. You can checkout the samples from the github for some examples. The computer-database example, has the following routes.conf:
# Delete a computer
POST /computers/:id/delete controllers.Application.delete(id:Long)
The bad request response could be related with the content-type of your request or the post content itself, and nothing to do with the nested routes.

Jmeter 2.9 HTTP Sampler for PUT not passing parameters

I'm using Jmeter version 2.9, HTTP sampler to test my rest services.
The GET and POST are working without any issues, where as PUT is not passing any parameters in the request to the server.
I verified it with view results in tree.
Any reasons on why this is happening and work around this issue?
It worked for me. Based on what I read on internet, there were different solutions suggested:
Changing Content-Encoding to UTF-8
Pass the PUT parameters in the "body data" tab (as opposed to passing them in tabular format in the "Parameters" tab)
Setting Content-Type header to application/json in the HTTP Header Manager
Passing the parameters via a file (even if this were to work, how would you pass dynamic values?)
passing it as POST with a combination of above points.
WHAT WORKED FOR ME is this combination: Set content type to application/json + Pass parameters as "JSON" in the **body data tab (below is an example)
I did not need to specify UTF-8 or anything else.
EXAMPLE JSON PARAMETER BODY:
{"title":"JMeterTitle","preMortar":"JMeterPre","postMortar":"JMeterPost"}
Pass parameters in path field using:
?name=value&name2=value2
and body in Raw Post body.
if it doesn't work report a bug .
Example:
I am using JMeter 2.11 and I had the same problem. I solved in this way:
1) Setting Content-Type header similar to that you are using in your api method(Example: application/json or application/x-www-form-urlencoded etc.) in the HTTP Header Manager.
2)In HTTP Request. Body Data should look like this:
KEY=VALUE&KEY=VLAUE&KEY=VLAUE&KEY=VLAUE.......
First, try see the logs.
Had a similar problem.
I was using wrongly the "Content-enconding" field as it were the HTTP
Content-Type param. They are not related.
If you need to set Content-Type=application/json you have to use a "HTTP Header Manager" config element.
After setting correctly Content-enconding to UTF-8 the put request started to work.
You should add a parameter with an empty name (in the "parameters" tab).
If the problem persists use the result tree view to analyze the request settings.
I'm using JMeter 2.13 and facing with similar problem. This is How I've solved it:
Setting Content-Type header to text/plain in the HTTP Header Manager
Changing Content-Encoding to UTF-8
In the parameters tab, add the params without name and separated with ampersand character (&)
Screenshot JMeter PUT request example
Hope it helps!

Resources