App Inventor post JSON to server - app-inventor

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...

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.

drf_yasg and amazon api gateway returns json instead of html ui

I have setup my python api service using djangorestframework and I am using drf_yasg for showing swagger docs for my api.
Here is glance of setup:
schema_view = get_schema_view(
openapi.Info(
title='My API',
default_version='v1',
description='rest service',
terms_of_service='',
contact=openapi.Contact(email='my#email'),
license=openapi.License(name='BSD License'),
),
public=False,
)
urlpatterns = [
path('pyapi/weather/', include('apps.weather.urls')),
re_path(r'^pyapi/swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^pyapi/swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
re_path(r'^pyapi/redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]
Next I setup this api with amazon ec2 and stuff, and I am using Amazon API Gateway to access the api from containers.
Now the problem is when I try to access that using api gateway domain, it returns swagger JSON instead of HTML.
I tried several things like setting Content-Type mappings in method response and integration response but nothing works.
In my local machine it shows html as expected, so I am suspecting problem is in my gateway settings.
I highly appreciate if someone can help!
Ok I solved mystery!
After tons of tries and looking here and there, I found there was problem in API Gateway Request header setting.
Actually drf-yasg also kind of weird let me tell you why.
After setting up urls as I shown in first image, if you try to access http://localhost:8000/pyapi/swagger/ it shows UI perfectly.
At that time value of request header is Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Now same URL if you pass request header "Accept: application/json" then istead of showing html UI, it shows swagger JSON! wutt!!
That I found in Amazon API Gateways's test method's output. It was by default sending "Accept: application/json" and thats why I was always getting swagger.json in output. That was showstopper thing!
I changed it to Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 and now I could see UI perfectly!
I hope this will save time of many other people like me who are new to this kind of stuff!

Symfony2, jQuery Ajax request, web debug toolbar, 500 Internal Server Error

I am developing an application with Symfony2 platform that, at one moment, makes a simple AJAX request on document ready.
jQuery.ajax({
url: 'test.php',
type: 'POST',
data: {
'test': 'test'
},
success: function( response ){
jQuery( 'div#container' ).html( response );
}
});
The problem is that on app_dev.php, where the debug toolbar is loaded, an 500 error is throwed.
More precisely, the AJAX response from the 'test.php' file is received and loaded in the div container, but then, when it tries to load the toolbar, I receive an alert message:
"An error occured while loading the web debug toolbar (500: Internal
Server Error). Do you want to open the profiler?"
If I open profiler, I don't see anything wrong.
If I open the xhr request for the toolbar, a FastCGI 500 error is displayed:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP54_via_FastCGI
Error Code 0x000000ff
If I don't try to make the AJAX request, the toolbar is loaded with no problem.
If I make the request by hand (event on a button) after the toolbar is loaded, again, no problem. If I make the request by hand (event on a button) before the toolbar is loaded the error is throwed.
Notes:
This error occur only on the local machine (with ISS 7.5, PHP 5.4.14). On the production server (IIS server 8.0, same and PHP) the AJAX request is made, and the toolbar is loaded with no problems. I have replaced the php.ini on the local machine with the php.ini from the production server - same problem.
Initialy AJAX request was loading the result of a simple bundle controller method, but then I have tried with a simple PHP file 'test.php', same problem.
I have tried with post and get methods to make the request.
Does anyone have any ideea what goes wrong?
This is not a serious problem since I have multiple options the develop this app, but is bugging me, and I already lost a enough time with this.
PS: if it make any difference, on same machine I have developed an application - no framework - that makes, multiple simultaneos ajax requests.
The following will not fix your error, but provides an alternative way to possibly achieve your need. It seems you want to load asynchronously a part of your website, Symfony2 provides a solution for that: ESI render.
The doc is here: http://symfony.com/doc/current/book/templating.html#asynchronous-content-with-hinclude-js
This method will create an ajax call only then your page will be rendered.

Fine Uploader Response Error OnComplete In IE 10

Manual Uploader Working Fine with All Browser expect IE 10, i am not getting correct Response From the Server it is Showing on onComplete "No Valid message Received from Loaded iframe For i frame Name 1_97604 cec......".
File are uploading into the cloudbees server but not getting correct Response From the server.
In case of Other browser i am getting Response.success = true, but For IE 10 its undefined, how to handle this error. Please help me Out for this.
Regards
Yogesh
You aren't using IE10 if that is the message you are seeing. Most likely, you are using IE9 or older. The message you are seeing is logged by the form uploader, which is never used if you are uploading via IE10. Perhaps you are running IE10 in IE9 or IE8 mode. Either way, the message indicates that you are working in a cross-origin environment (you have set the cors.expected option to true) but are not returning the proper response from your server. Note that older browsers, such as IE9 and older, utilize form submits, targeting an iframe, to upload files. In order to access the contents of that cross-origin iframe, the iframe needs to post a message containing the server response to Fine Uploader's window. This is all very easy to do, all you need to do is return a text/html response from your server that looks something like this:
"{\"success\": true, \"uuid\": \"9da17ad5-ad6a-40cd-81b5-226e837db45b\"}<script src=\"http://<YOUR_SERVER_DOMAIN>/iframe.xss.response-<VERSION>.js</script>.js\"></script>"
The javascript file mentioned in the script tag is provided in the Fine Uploader released zip file. It does all of the work for you. You must return a JSON response before the script tag, as illustrated above, and the response must include the UUID of the associated file.
You should read about cross-origin support either in the associated blog post.

Grails Canoo Webtest plugin: invoke() fails to send JSON data in POST request

I'm evaluating Canoo Webtest for automated integration/functional testing as a Grails plugin.
I have a REST app which I'm attempting to test, but Canoo Webtest doesn't seem to properly send the JSON data in POST request. My test code is like below
invoke( description:"Add a product to shopping cart",
url:'shoppingCart/add', method:'POST',
content:'{"class":"shop.service.Product", "name":"A product", "description":"Manufactured by X", "price":99.9}'
//contentFile: '../product.json'
)
The request body is empty no matter whether I use contentFile approach or inline the data as content attribute. The test report shows the data as being sent correctly, but error page shows an error stating 'JSONException: Missing value. at character 0 of '. JSON data as a response of GET request is coming back fine.
I have tested the same functionality with curl and it works perfectly fine. Is there something I'm missing in the Canoo Webtest setup?
Thanks.
EDIT: I'm using Grails 1.3.7 in case that makes any difference
OK. I started to just experiment with the invoke() and seems that setting attribute soapAction value to true does the trick.
I have no clue why this works. The documentation of invoke() for the attribute says
soapAction
Required? no
If the HTTP method is POST and is in fact a SOAP POST request,
this allows the SOAP Action header to be set. Ignored for GETs.
Apparently it sets some needed request header. Haven't checked which one.
Thank you for reading :)
Cannot yet mark this answer as the correct one, but will do so when it's possible.

Resources