OKHTTP POST Data using form builder with integer parameter - okhttp

I Wanna ask a question,
I want POST data to API that have parameter with integer data type, I already convert my parameter request that have integer value to string because Form Builder just accept String value.
But the server that I want to send expect integer value.
Is there any solution that I can use ?
The Server using header : Content-Type : x-www-form-urlencoded;
Thank you

Related

How can i send UUID object as parameter in HTTP Request Body data?

I have UUID value converted from String:
String SessionUUID1= "8B6FA50D-59D0-4582-9396-C4A376EBBC7E";
UUID finaluid = UUID.fromString(SessionUUID1.toString());
but unable to assign it to Jmeter variable and also unable to pass it as Json data in body data.
I should assign finaluid as json data to send the request.
Iam using Beanshell Preprocessor to populate the above.
You can use vars.putObject method to store non-String variable value like:
vars.putObject("finaluid", finaluid);
Not sure what do you mean by I should assign finaluid as json data, if you sending JSON via HTTP Request Sampler - it won't accept UUID, you'll have to convert it back to string.
Check out How to Use BeanShell: JMeter's Favorite Built-in Component article for some Beanshell examples and explanation of pre-defined variables.

Asp.net web api 2 datetime input parameters change localisation

I send a request from javascript to web api controller for example, ../api/person/updateBirthDate?id=1&birthDate=dd/MM/yyyy
I'm not sending json format so please don't say use Json serilizer. I just use post an url with parameters like form submit. How can I solve this issue at server side in order to get the date formatted as dd/MM/yyyy
First of all, the splash / is not allowed in the URL parameters. Use %2F instead. So the URL:
../api/person/updateBirthDate?id=1&birthDate=01/01/2000
should be sent as:
../api/person/updateBirthDate?id=1&birthDate=01%2F01%2F2000
Now, on your server, all the URL parameters will arrive as string, so you need to parse them like this:
int Id = Convert.ToInt32(Request.QueryString["id"]);
DateTime BirthDate = Convert.ToDateTime(Request.QueryString["birthDate"]);

How to send Object via Ajax to Servlet

How do I send an element of type object via ajax to a servlet?
In the ajax I am passing the value as follows below:
data: { mapList : mapLists }
To get the value in the Servlet am doing follows below:
Object o = request.getAttribute("mapList");
System.out.println(o);
However, the returned value is always null. What should I do to get around this problem?
Change your ajax datas by :
data: { 'mapList' : mapLists }
On HTTP GET or POST requests you can only send a list of key/value pairs as parameters to the server so you will have to manually serialize your object to send its attributes in this format.
You should better use HttpServletRequest.getParameter(String) in place of HttpServletRequest.getAttribute(String). Also, what you get as an HTTP GET/POST parameter will always be received in the servlet as a String.
I assume that you are using jQuery to send the ajax request. I also asume that your mapLists variable is a json object. As far as I know, jQuery doesn't automatically convert a json object to a key/value pair HTTP parameter list so you will have to do it by yourself and then parse it back in the servlet. You can use JSON.stringify() to convert your json object or you can serialize it manually.

need the query string from the request to use with the input attribute of the action mapping

I am using struts 1.3.10. I need the query string from the request to use with the input attribute of the action mapping so that when validation fails, the forward goes to correct page without any null pointer exceptions. how can I do this? I do have the entire forward(myAction.do?foo="bar") as a form property posted throught he jsp. Plesae let me know if I am not clear on the problem definition.
Have you tried request.getQueryString()?
Example:
String queryString = request.getQueryString(); //where "request" is "HttpServletRequest"

Spring Passing request parameter

I want to pass parameter (a String value) to spring controller from a jsp
What is the best or recommended way to do it.
-I don't want to send parameters in URL - #RequestParam may not be suitable
-Should I hook the parameter to a model object and use #ModelAttribute. What if I want just a string value to be passed.. should I create a object with just a string attribute for this purpose?
-Use HttpSevletRequest
Use #RequestParam - it will work with both GET and POST requests. So if you don't want to send them in the URL, use the POST method to submit your form.

Resources