When testing the following URL string out in the Graph Explorer I get the expected return
me?fields=albums.limit(10){name,photos.limit(1){images}}
But when calling
FBRequestConnection.startWithGraphPath("me?fields=albums.limit(10){photos}",
parameters: nil,
HTTPMethod: "GET")
{ (connection: FBRequestConnection!,
result: AnyObject!,
error: NSError!) -> Void in
println(result)
}
It says that it's an unsupported URL. Do I need to access these properties via the 'parameters' option instead? I so, how do I go about that? I can't seem to get my head around it.
Any help is greatly appreciated
Chris
I had similar problem when I tried to get my feed and found no answers.
What I discovered is the URL format in Graph Explorer and iOS SDK is different.
iOS SDK don't like curly brackets, so your request for example should look like:
"me/albums?fields=photos"
In my case, that syntax works great. Unfortunately I have no idea how to specify the limit there.
//Edit:
To use modifiers like limit, you can do that this way:
"me/albums?fields=photos&limit=10"
Try referencing the albums fields like this:
"me?fields=albums.limit(10).fields(images)"
Related
I'm using FirebaseFirestoreSwift and Swift5.5 on iOS15+
I have this query:
#FirestoreQuery(
collectionPath: "/Users/" + Auth.auth().currentUser!.uid + "/Pages/"
) var pages2: [PageItem]
And I'm trying to get the following:
The structure is: /Users/{userId}/Pages/{pageId}/{key/value pairs}
I even confirmed from Firestore that the path was matching with its own.
This is from the console: /Users/JuzWOzAf54a7oFlOlb09dhAuOjI3/Pages/LZQAmbb18tYtz8ypkd8p
and this is what my string concatenation produces: /Users/JuzWOzAf54a7oFlOlb09dhAuOjI3/Pages/
So I should be getting the Page LZQAmbb18tYtz8ypkd8p and 3 others in the response, but thus far it is empty. Am I checking too early?
I am printing it like so:
.onAppear {
print(pages2)
}
On a view in the same file.
I don't even think it's a problem with printing it too soon, since it's meant to update in real-time.
But just incase it never showed since it was onAppear,and could have been received after, I added the following:
List {
ForEach(pages2) { page2 in
Text(page2.name)
}
}
And still, it receives nothing.
Not really sure what I'm doing wrong, I've researched and all I can find is a few resources, but they all seem to be doing the same thing, however, mine is simply not working, or I might be confused.
Any help is greatly appreciated, thank you!
Edit
This is the official SDK file whose methods I'm using:
https://github.com/firebase/firebase-ios-sdk/blob/master/Firestore%2FSwift%2FSource%2FPropertyWrapper%2FFirestoreQuery.swift
I am doing exactly as they propose.
I am trying to Put and Delete data through Almofire Library but facing issue regarding parameters. Params are missing, following are the error:
Response JSON data = {
data = "<null>";
issuccess = 0;
msg = "{'car_id': [ErrorDetail(string='This field is required.', code='required')], 'car_brand_id': [ErrorDetail(string='This field is required.', code='required')], 'last_oil_change': [ErrorDetail(string='Date has wrong format. Use one of these formats instead: YYYY-MM-DD.', code='invalid')]} with error { Custom error message. }";
}
I am using the following code:
let params : [String : String] = ["brand_model_id": String(car_model_id), "oil_brand_id": String(oil_brand_id), "car_mileage": edCurrentMilage.text!, "car_modelyear": edVehicleModelYear.text!, "last_oil_change": edLastOilChange.text!]
Alamofire.request(Constants.APIURL + Constants.APIPOSTCARDATA ,method:.put, parameters: params, encoding: JSONEncoding.default, headers: header).responseJSON { [self] response in
guard response.result.isSuccess,
let value = response.result.value else {
print("Error while fetching tags: \(String(describing: response.result.error))")
self.hideIndicator()
// self.btn_submit_outlet.isEnabled = true
// completion(nil)
return
}
print(value)
let json = JSON.init(value as! NSDictionary)
print(json)
let code = json["issuccess"].boolValue
if(code)
{
self.hideIndicator()
Commons.showAlert(title: "Alert", error: "Data has been added.", VC: self)
}
else
{
self.hideIndicator()
Commons.showAlert(title: String.localizedStringWithFormat(NSLocalizedString("Alert", comment: "")), error: String.localizedStringWithFormat(NSLocalizedString("Something went wrong.", comment: "")), VC: self)
}
}
Above mention code is used for the PUT call Please help. Thanks in advance.
It's not against you particularly, BUT, it's something that is lacking a lot in this kind of questions.
Usually, by reading output error, in our case the server response we might, and I insist on "might", find the solution. But it's not always the case, sometimes error message is too generic, or pointing to the wrong direction. Here, error is saying about missing "car_id" param, but according to you it's not needed, so it's misleading (if we believe your saying).
Another usually good hint, is saying that "It's working on Android", "It's working in Postman", "It's working with a cURL command".
Usually, when this happen, I'm asking myself:
Why the author doesn't show the Postman, Android code, cURL command that would allow people knowing both tools/languages/platforms to spot a difference that could be the mistake.
Let's be honest, that would be easier, no? You might have quickly the right solution/fix, no? It's better than trying to guess battling agains the server response, no?
Now...
You are using Alamofire AND Postman. What if I told you that might be enough for you?
Quick trivia:
Did you know that Postman can generate code for the request?
It can even generate Swift Code for your request using URLSession? It's not "beautiful", "swifty" Swift code, but it's enough to spot difference and find why it's working on Postman and not in your code.
It can also generate cURL command? If you don't know about cURL a quick explanation would be "command line tool to make web request with params etc in Terminal.app/Bash/Shell, ie: it's basic and usually known by a lot of developers, so even if you only speak JavaScript, Java, etc, it's often like a "common language"
How? Even when I say that in comments, people don't even try to search for it... Let's find it with your favorite Search Engine, which should lead you to this tutorial/blog post. And tadaaa!
Did you know that AlamoFire can print request as cURL equivalent? It's stated here.
So in your case, what about asking Alamofire and Postman to generate cURL command and compare?
Then, you might want to change the parameters of the request, or even the parameters of the method request(_:method:parameters:encoding:headers:).
Why I am saying this?
Because if you don't give enough informations, there will be a delay between someone asking for more info/details in comment and yourself responding to them. Also, different commenters will ask for different questions, since debugging is a skill and causes might be multiples, we might ask different things, and only one will be relevant in the end to your issue, but we can't guess which one until then.
Because spotting difference is easier and might attract quicker response.
Now that you know about POSTMAN and Alamofire and cURL, you might even find yourself the solution. Even quicker than making a question on SO! Be your own hero!
In the end, only an "attractive" question will have good answers, so give as much info as possible, don't hold them (parameters sent, equivalent android code, screenshot at least of the Postman, but know that you know about the cURL generation code). Of course, keep your private token etc, obfuscate them a little, but still, you might have watch enough TV shows/movies where holding info is bad for the main characters, why repeating that mistake here?
As the error message says: Date has wrong format. Use one of these formats instead: YYYY-MM-DD.
Please check "last_oil_change" field. The value is from edLastOilChange.text. Does edLastOilChange.text meet the required format?
Getting error "GoogleJsonResponseException: API call to slides.presentations.batchUpdate failed with error: Invalid requests[3].updateShapeProperties: Invalid field: autofit_type"
but I think my code is right:
'updateShapeProperties': {
'objectId': pageElementId,
'fields': 'autofitType',
'shapeProperties': {
'autofit': {
'autofitType':'SHAPE_AUTOFIT'
}
}
}
Any help much appreciated
Cheers
Greg
I thought that the error message means that the value of fields is not correct. In your script, how about modifying as follows.
From:
'fields': 'autofitType',
To:
'fields': 'autofit.autofitType',
Note:
But, in the current stage, it seems that the value of autofitType can only use NONE. So, when SHAPE_AUTOFIT and TEXT_AUTOFIT is used for autofitType, an error of Autofit types other than NONE are not supported. occurs. Please be careful this.
About this, it seems that this is not reported as the future request in the issue tracker. So how about reporting it as the future request? Ref
When you test above modification, please modify 'autofitType':'SHAPE_AUTOFIT' to 'autofitType':'NONE'. By this, the request occurs no error.
Reference:
AutofitType
You're using an invalid field as what the error message says.
You can refer here for the available fields that can be used to replace your 'autofitType' field.
In response to Jason E. response, please see the documented Enum for AutofitType 1
I want to examine http requests in an extension for firefox. To begin figuring out how to do what I want to do I figured I'd just log everything and see what comes up:
webRequest.onResponseStarted.addListener(
(stuff) => {console.log(stuff);},
{urls: [/^.*$/]}
);
The domain is insignificant, and I know the regex works, verified in the console. When running this code I get no logging. When I take out the filter parameter I get every request:
webRequest.onResponseStarted.addListener(
(stuff) => {console.log(stuff);}
);
Cool, I'm probably doing something wrong, but I can't see what.
Another approach is to manually filter on my own:
var webRequest = Components.utils.import("resource://gre/modules/WebRequest.jsm", {});
var makeRequest = function(type) {
webRequest[type].addListener(
(stuff) => {
console.log(!stuff.url.match(/google.com.*/));
if(!stuff.url.match(/google.com.*/))
return;
console.log(type);
console.log(stuff);
}
);
}
makeRequest("onBeforeRequest");
makeRequest("onBeforeSentHeaders");
makeRequest("onSendHeaders");
makeRequest("onHeadersReceived");
makeRequest("onResponseStarted");
makeRequest("onCompleted");
With the console.log above the if, I can see the regex returning true when I want it to and the code making it past the if. When I remove the console.log above the if the if no longer gets executed.
My question is then, how do I get the filtering parameter to work or if that is indeed broken, how can I get the code past the if to be executed? Obviously, this is a fire hose, and to begin searching for a solution I will need to reduce the data.
Thanks
urls must be a string or an array of match patterns. Regular expressions are not supported.
WebRequest.jsm uses resource://gre/modules/MatchPattern.jsm. Someone might get confused with the util/match-pattern add-on sdk api, which does support regular expressions.
How can I print a map from the OpenLayers? I want to add print button in my OpenLayers page =) I have MapFish extension for my geoserver, but don`t know how to make request to it. Any other ideas are welcome) Help please.
I had a similar problem using a reverse proxy, because I discovered the answer from info.json contais local ip reference instead of the public url
to solve brutally i replaced the ip referenze with the public url in the ajax request (see the following code. I hope it can be usefull for others...
this.capabilities.createURL = this.capabilities.createURL.replaceAll("192.168.0.0:8080", "mypublicurl");
this.capabilities.printURL= this.capabilities.printURL.replaceAll("192.168.0.0:8080", "mypublicurl");
Ext.Ajax.request({
url:this.capabilities.createURL,
jsonData:jsonData,
success:function(response){
response.responseText = response.responseText.replaceAll("192.168.0.0:8080", "mypublicurl");
window.open(Ext.decode(response.responseText).getURL);
}
});
The simplest way is to use GeoExt.PrintMapPanel (geoext example). And be sure to read GeoServer Printing Module.
UPD GET request example. You must modify url, "baseURL", "layers". If you specify an existing layer, this request must return pdf file.
http://demo.opengeo.org/geoserver/pdf/print.pdf?spec={"units":"degrees","srs":"EPSG:4326","layout":"A4","dpi":75,"mapTitle":"Printing Demo","comment":"This is a simple map printed from GeoExt.","layers":[{"baseURL":"http://demo.opengeo.org/geoserver/wms","opacity":1,"singleTile":true,"type":"WMS","layers":["topp:tasmania_state_boundaries"],"format":"image/jpeg","styles":[""]}],"pages":[{"center":[146.56000000001,-41.56],"scale":8192000,"rotation":0}]}