I get the JSON of User Info from Facebook on Android.
And then send the JSON to my servlet (the platform is GAE).
My question is how to send it properly.
Since the JSON could be very long.
So far, I have tried this way.
But I cannot receive the entire JSON.
It always throws
Unterminated string at character 117 of
{"music":{"data":[{"created_time":"2011-05-23T16:47:21
0000","id":"176345129540","category":"Musician/band","name":"
And I print the JSON, I find that the JSON is just as above which is been cut.
Thanks in advance.
There might be a limit on the size of data you can send by Http GET, take a look at this question and rewrite your request to use Http POST.
Related
I am working on a web application where on clicking a button on the UI a GET request is made to the server as below:
https://mywebapp.com?info=%5B%7B%22first%22%3A%22abcd%22%2C%22second%22%3A%22efgh%20ijkl%22%2C%22third%22%3A%22mnop%22%7D%5D
Basically the value I am passing as info is:
[{"first":"abcd","second":"efgh ijkl","third":"mnop"}]
However, when I read this passed value on server, I found it to be received as:
[{first:abcd,second:efgh ijkl,third:mnop}] i.e. all the double quotes are removed.
Now when I try to parse it into json, it fails.
Could you please suggest how could I fix the issue so that the json is received as expected.
Please note that it is an existing big application and I can't change any server level settings.
Thanks
To keep the double qoutes as is you have to send the json in single qoutes
i,e convert the json into string then send it, because the GET/POST request don't recognize json format
I'm start learning java programming, and I want make a simple server application. I read about com.sun.net.httpserver.HttpServer and find a good example on this link: https://github.com/imetaxas/score-board-httpserver-corejava.
I understand how to do Get-request in url, but I don't know how POST works. I think it must be sent a form or data on the server.
I attach the link of project, which I'm learning, in readme the author wrote http://localhost:8081/2/score?sessionkey=UICSNDK - it's not working...
I wrote in url and get sessionkey: "localhost:8081/4711/login --> UICSNDK"
I wrote in url this for Post request: "localhost:8081/2/score?sessionkey=UICSNDK" - not working and in chrome return 404 bad request
3.wrote in url this:"localhost:8081/2/highscorelist"
Please help me, I am beginner.
The difference between GET and POST is that with a GET request the data you wish to pass to the endpoint is done by modifying the url itself by adding parameters to it.
With a POST any data you wish to send to the endpoint must be in the body of the request.
The body of a request is arbitrary data that comes after a blank line in the header The reqiest has the request line, following by any number of header attributes, then a blank line.
The server would need to know what the format of the body of the request was and parse it as appropriate.
Of course 'modern' frameworks like jax-rs allow you to automatically convert request data to objects, so that it is much simpler.
Hi are there any frameworks or libraries in php equivalent to jpos?
I came across JAK8583 php library which can parse and generate ISO 8583 messages.
However I want a php library which can generate ISO 8583 response message for ISO 8583 request message .
Please let me know if there are any.
Hi I don't know any alternative but you can always parse the request and set the response fields on that parsed request.
You can see implementation of ISOMsg.setRespnseMTI as inspiration.
Regards
You can check out this php library for iso8583.
Please note that in general you cannot throw a request at a library and tell it to give you a response that will be useful. You need to populate the response with data that is relevant to the transaction.
So normally you would get the request, create a response from the request, populate the response with relevant data, then send it.
I'm working on a game using the LibGDX library. One part of the game involves collecting game data and sending it to a server as a JSON array to be recorded in a database. I'm using Node as my server but I'm running into an issue every time the game sends a POST request to the server. I'm using LibGDX's Http.Net library to send the request.
I keep getting a HTTP 400 error message and data isn't being recorded. Attached are screenshots of the relevant code and messages. Thank you!
Images: https://imgur.com/a/CF1U6#0
I don't have enough reputation to insert images, sorry.
I figured out the problem. I was using LibGDX's included JSON library to construct my JSON String. However, when I created Json json = new Json();, it defaults to writing minimal (I think). Names are not surrounded by double quotes in this format. See: https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/JsonWriter.OutputType.html
The solution is to set it to Json json = new Json(JsonWriter.OutputType.json);. This will format it as JSON which Express will recognize.
I am creating a REST API on top of an existing application. One of the features takes in a json data along with a file uploaded by the user.
I am unsure how to send a file AND json data in the same request to the REST API?
I have the json part working and I test that using curl:
curl -XPOST http://localhost:8080/myapp/foo -d '{"mydata": {
"name": "somename",
"gender": "male"
}}'
//I would like to send an image (say, profile image) with the above request as well.
I'm using a grails application so I get this data in my controller like so: new Foo(params.mydata).
Question
Is it possible to send JSON data and a file in the same request to the API? If so, how can I do it using curl or REST Console (chrome extension)
What would be the contentType of this request?
I'm open to sending data in another format if it means that I can send file and other data (strings) within the same request. I'm not tied on JSON
Update
I found another SO question which is asking the same thing. From the answer to that question it seems there are only three choices and none of which say that its possible to send both, json data and file, within the same request. Which is very discouraging...I will keep this question open to see if anyone has other ideas.
I think the "right" way to do this is with a multipart message. That way, you can post up both the JSON and the Image with their corresponding correct MIME type. The wikipedia article on multipart mime types has an example of what this would look like. It looks like both Apache httpcommons and Jersey support this sort of thing, and apparently curl does too!