I'm using Django and DRF, and I have a view that retrieves a Binary File (Using BinaryFileRenderer) from an external API. This external API brings the binary data from S3.
I need to mock this call so I could test the logic by isolating the API call, but every time I tried I received some error. For example, I tried creating a MockFile class with content, mime_type, and name fields. And I started to receive the error "AssertionError: renderer returned Unicode, and did not specify a charset value."
After some investigation, apparently, it was expecting some kind of Renderer file. But this is when I got confused. Because Python is dynamic, I'm never sure what kind of file I received and I'm not sure how I can mock the binary file I'm receiving.
Anyone can point me to how correctly mock this binary file?
Related
Good morning. I am new to logic apps and I am trying to figure out how I can trigger the execution based on a GET URL with three parameters. All the examples I've found on Google show the URL being generated once the JSON and relative path is entered, but that's not happening for me. Perhaps it's because I am creating the logic app in VS.
Here's what my "When a HTTP request is received" step looks like in the logic app.
I also tried removing the JSON and just using the parameters to pass the values to the function, as shown below. I'm just not sure the best way to do this.
All I really need to do is get the three parameters into the logic app so I can perform a function call with the parameters. Any suggestions would be greatly appreciated!
Why is my HTTP request URL not being generated for a Logic App?
You need to click save, and then the url will be automatically generated for the When a HTTP request is received trigger:
You can use this expression to accept values through GET parameters:
triggerOutputs()['queries']['parameter-name']
For example:
Noteļ¼
Queries need to pass parameters in the form of json.
I have a piece of file access code which uses FSGetCatalogInfo to get info about a bundle (say .xyz) which itself contains a file with extension .xyz. Because FSGetCatalogInfo has been updated, I am looking to replace it with 'getResourceValue' API from Foundation layer. However, the OSType is coming incorrect from the new API.
I have also looked into the related FSSetCatalogInfo API. Do I need to do something equivalent such that the 'getResourceValue' API will start giving correct results?
I have an Azure Mobile service with a .Net back end.
In the backend the data object use proper case. for example, MemberNumber.
In the azure client the view models use pascal case memberNumber.
I am using a library that creates an ODATA request and I get:
The query specified in the URI is not valid. Could not find a property named 'memberNumber' on type 'arenaapi.DataObjects.Members'.
That happens with this get:
/tables/members?%24inlinecount=allpages&%24orderby=memberNumber
If I change that the MemberNumber it works.
However, also, if I change the request to:
/tables/members?%24inlinecount=allpages&$orderby=memberNumber
It also works. It seems that the model binding parser is working differently if the $ is encoded or not.
Is there any way I can fix this server side so the encoded request won't return a 400 without changing the memberNumber to MemberNumber?
All the other stuff, posting, patching, etc is properly binding the pascal cased JSON post to proper cased c# data objects.
I am trying to work out a way to provide a CSV download through a Spring 3 Portlet. I have a method that uses the #ResourceMapping annotation to define a handler that takes some report params in the form of a #ModelAttribute, builds the report, and returns it. The catch-22 I am running into is validating the parameters being send in from the client form.
If I make the handler a #ResourceMapping, I can set the headers and write out the report as using the ResourceResponse, but I can't seem to figure out how to redirect the user back to the Portlet view with errors when their input fails validation. However, if I make it an #ActionMapping, I can then check the BindingResults and forward them back to the form as needed, but the ActionResponse doesn't allow me to set the Content-Disposition header nor write out the CSV bytes, which is sort of critical for sending the report back.
I am at a total loss here, as I don't even know what my options are. Is it even possible to do what I am trying to do with a Portlet? Are there other examples I could look at for a possible work-around?
I suggest you to use both #ActionMapping and #ResourceMapping to fulfill your requirement.
As you said you were able to handle the validation errors using the #ActionResponse, I'll tell you how to handle the Resource Streaming.
As you know every #ActionResponse is followed by a #RenderResponse, just return the same view but, with a hidden iframe this time whose src points to the ResourceURL.
Now the Request you receive in #ResourceMapping is something which is already Validated. So, you can now serve your CSV.
I dont know how complex is your UI and if you are using jsp as views in your application. If nicely managed, Validation can be handled by #ResourceMapping.
Thank you
When I send the following query
http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=coffee%20New%20York%20NY
using c# WebClient.DownloadString function or ordinary web browser
I get JSON data which is different from data for the same query using JavaScript and
Google AJAX Search API.
From REST service I get the following url field
http://www.google.com/maps/place?source003duds0026q003dcoffee0026cid003d13245583795745066822
but from JavaScript query I get this url field
http://www.google.com/maps/place?source=uds&q=coffee&cid=13245583795745066822
The problem with REST service answer is that the url it gives points
to a web page with error message "We currently do not support the location".
What am I doing wrong?
It looks like either you are decoding the URI from the REST request incorrectly, or Google is ending it wrong. The = are being sent or parsed as 003d and the & as 0026
EDIT : After trying that link I see they return the links, in the JSON, with the '=' and '&' encoded, the JavaScript must be replacing those characters for you automatically. You could do a simple String replace on "003d" and "0026" - although I'm not sure that will cover every use case.
I resolved this by parsing JSON data with Json.NET library http://json.codeplex.com/