Nativescript app not reading http/json data - nativescript

I have this app in the playground:
https://play.nativescript.org/?template=play-tsc&id=Azbs38&v=3
In the device log I am seeing SyntaxError: JSON Parse error: Expected '}' but I am not sure why. The JSON I am calling is valid. What might the problem be?

Looks like the response header content-type being returned is text/plain.
It should be application/json.

Related

React Native form data request failed with no multipart boundary was found

I'm struggled with react native file upload using Axios form data. I set the content type as multipart/form-data. below is my request parts.
form-data body content
{"_parts":[["profileImage",{"name":"rn_image_picker_lib_temp_51ee6068-2b4b-4baf-a6c3-44b14b0b5b9b.jpg","type":"image/jpeg","uri":"file:///data/user/0/com.sentura.xchange/cache/rn_image_picker_lib_temp_51ee6068-2b4b-4baf-a6c3-44b14b0b5b9b.jpg"}],["email","xx#gmail.com"],["firstName","vv"],["lastName","ss"],["address","sdf"],["postalCode","2323"],["mobileNumber","0796677653"],["country","Anguilla"],["countryCode","+1264"]]}"
request headers
"headers":{
"Accept":"application/json",
"Authorization":"Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ2aWR1OTk2QGdtYWlsLmNvbSIsImV4cCI6MTY0NTk1ODYzNywiaWF0IjoxNjQ1OTU3NzM3fQ.GZMQFYGU4veH4xZ9ki2afWmtbGCKhOK5JruWLRX75nisVXXX9JmQYf31ns_ALVr9N1-RgcpMabolgHQSMZ7KIw",
"Content-Type":"multipart/form-data"
}
but from the spring boot side, it gives the below error. but this work in postman.
org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found
Hope your support to resolve this. thanks!
This works for me:
"Content-Type" : 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
Actually the issue happened with my react native version. i don't know what is the correct way to achieve it with newest react native versions. i worked with react native 0.67. unfortunately, it's broken.
I added the same code base to react native 0.64 and it worked well as i expected. didn't do any code change to axios or any other.

Spring SOAP Mtom attachment's identifier encoding problem

I created a SOAP client in my Spring Boot (2.5.5) server.
The envelope is marshalled, the communication works, but I have got an error which said I not attached the binary (file) data.
In my log file the soap message has it and there is a binary attachment.
The only strange thing is, in the Include tags href attibute has a %40 character instead of # character like this:
...
<ns2:DocuData xmlns:ns2="namespace 1">
<ns2:fileContent>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"
href="cid:946ff3f8-e725-4cca-8108-676403be336f%40domain.hu"/>
</ns2:fileContent>
</ns2:DocuData>
...
In the multipart data section the Content-ID is:
...
------=_Part_1_22457057.1633284795352
Content-Type: application/octet-stream
Content-ID: <946ff3f8-e725-4cca-8108-676403be336f#domain.hu>
Content-Transfer-Encoding: binary
...
content
...
------=_Part_1_22457057.1633284795352--
Is it the cause of the problem? How can I solve it?
Thanks for any help!
It was my fault! I read out the data from the stream when I logged the request in the interceptor. I turned off the logging and the message sent successfully.

Accessing API layer

I am trying to access an api function, for example I want to access the login function, I get the following error:
"message": "An internal error occurred during your request!",
Looking in the log file, the following log is there:
ERROR 2017-10-09 17:01:37,296 [11 ]
nHandling.AbpApiExceptionFilterAttribute - Processing of the HTTP
request resulted in an exception. Please see the HTTP response
returned by the 'Response' property of this exception for details.
System.Web.Http.HttpResponseException: Processing of the HTTP request
resulted in an exception. Please see the HTTP response returned by the
'Response' property of this exception for details.
I am using Postman to test. My URL is https://localhost:44347/api/Account/Authenticate. My header has Context-Type as "application/json" and in my Body I have the loginModel formatted as
{
"tenancyName": "tenantname",
"userNameOrEmailAddress": "admin",
"password": "123qwe"
}
Am not sure how else to proceed on this. Any ideas please? I have swagger installed as well.
I am using MVC + AngularJS template. I have not changed anything, just the default project.
Appreciate the assistance.
I have tested with Fiddler and it works correctly.
Note: make sure you type Content-Type correctly, on the question you typed Context-Type
Make a POST request! You may be missing this.

App Inventor post JSON to server

I'm trying to post JSON data from App Inventor to server but error occurred and I don't know where the problem is.
I did it successfully with Scratch 2 and Firefox RESTClient. Both work fine, but not in App Inventor.
URL: https://api.myserver.com/v2/users/***
HEADER: Content-Type:application/json
BODY: {"in":true}
Your text to post is no valid JSON format, you can check it here jsonlint.com ...
You might want to try {"in": true} instead...
Btw. what about additionally posting the error message you get...You can get it in the Web2.GotText event...

Laravel request file upload with content-type won't work

When I remove content-type from Postman laravel request has the file, but if I add any content type in headers it is null? Problem is that browsers add content-type,and I can not exclude them to make it work? Any ideas? Thanks
You should probably get the Content-Type from the UploadedFile instead:
$request->file('form_input_name')->getClientMimeType();
The content-type of the entire request will be set to something like multipart encoding when you send a file with Postman.
I hope this helps.

Resources