I want to fetch LoginOperationResponseBody key from the following JSON response in Swift.
[
{
"LoginOperationResponseHeader": {
"ReponseCode": 1,
"ReponseType": "Success",
"ReponseDesc": "Login com successo"
},
"LoginOperationResponseBody": {
"UserName": "dev hélio africano monteiro querido varela",
"Email": "helio.varela#uniteltmais.cv",
"Perfil": "perfil_002",
"TipoCliente": "Particular",
"NIF": 0,
"PhotoId": 47212,
"NomeCompleto": "dev hélio africano monteiro querido varela",
"Number": 9100141,
"TipoClienteId": 1,
"TelefoneFixo": 0,
"UserID": 122,
"Morada": 0,
"ClientId": 22106,
"SessionId": "BBA72CDD-6BAA-4C22-AE95-8A674764CE7D",
"ClientNumber": 1000481
}
}
]
If anyone could help me would be appreciated. I can fetch it if there is a key on first array Object but how can I get it without key.
Thanks in advance.
let loginOperationResponseBody = response[0]["LoginOperationResponseBody"]
I found it by myself.
Related
when i do a post https://umuly.com/api/url with body : { "RedirectUrl": "www.youtube.com"}
i get this message:
{
"status": 400,
"statusText": "Value cannot be . (Parameter 'uriString')",
"item": ,
"itemCount": 0,
"skipCount": 0,
"requestDate": "2020-09-10T02:09:37.2912502-07:00",
"responseDate": "2020-09-10T02:09:37.2933547-07:00"
}
,undefined
You must be getting it because the protocol is not written.
You must write http:// or https:// at the beginning of the domain name
{ "RedirectUrl": "https://www.youtube.com"}
I have a Sagemaker endpoint that I can infer to from boto3 client and get response.
Per boto3 doc, the Body of the response result is a Byte object StreamingBody type. I convert it to a dictionary
response = client.invoke_endpoint(EndpointName=endpoint_name, Body=json.dumps(data))
response_body = response['Body']
dict_response = response_body.read().decode('utf-8')
print(dict_response)
The above code gives me a response like below (stripped down for this post)
I need to retrieve the array from the "floatVal" key. How do I do that?
{
"outputs": {
"score": {
"dtype": "DT_FLOAT",
"floatVal": [
0.00012408883776515722,
...........
-0.8316119909286499,
-0.24423488974571228
],
"tensorShape": {
"dim": [
{
"size": "1"
},
{
"size": "1024"
}
]
}
}
},
"modelSpec": {
"version": "1",
"name": "generic_model",
"signatureName": "serving_default"
}
}
Actually the dict_response is not really a dictionary here, rather a string type. So I had to convert the dict_response to an actual dictionary and then I could retrieve the floatVal key.
Updated code
response = client.invoke_endpoint(EndpointName=endpoint_name, Body=json.dumps(data))
response_body = response['Body']
response_str = response_body.read().decode('utf-8')
response_dict = eval(response_str)
print(response_dict['outputs']['score']['floatVal'])
I am trying to get get ownership information against AssetIDs through the Youtube ContentID API.
I can see the data that I need through the API Explorer but cant seem to drill down the data using dot notation.
Here is the output from the API explorer:
{
"kind": "youtubePartner#asset",
"id": "A146063471697194",
"type": "music_video",
"ownership": {
"kind": "youtubePartner#rightsOwnership",
"general": [
{
"ratio": 100,
"owner": "Indmusic",
"type": "exclude"
}
]
},
"ownershipEffective": {
"kind": "youtubePartner#rightsOwnership",
"general": [
{
"ratio": 100,
"owner": "Indmusic",
"type": "exclude"
}
]
}
}
When accessing the "owner" I receive undefined instead of the listed value.
var url2 = _.sprintf('https://www.googleapis.com/youtube/partner/v1/assets/%s?fetchMetadata=effective&fetchOwnership=effective&key=%s',id,API_KEY);
var result2 = JSON.parse(UrlFetchApp.fetch(url2, getUrlFetchOptions()).getContentText());
Logger.log(result2.ownership.general.owner);
returns undefined
I have tried both ownershipEffective and ownership and they are both undefined.
I can log data from result2.ownership.general but nothing below that.
You can tell that general is an array by the [brackets] in:
"general": [
{
"ratio": 100,
"owner": "Indmusic",
"type": "exclude"
}
]
Try:
Logger.log(result2.ownership.general[0].owner);
general, having been declared an array, requires a position [0] even though there is only 1 item in the array.
The Request:
[{
"method": "GET",
"to": "/node/1890",
"id": 0
},
{
"method": "PUT",
"to": "{0}/properties/Name",
"body": "NewName",
"id": 1
}]
The Response:
{
"message": "Illegal character in path at index 2: ./{0}/properties/Name",
"exception": "IllegalArgumentException",
"fullname": "java.lang.IllegalArgumentException",
"stacktrace": ["java.net.URI.create(URI.java:859)", "java.net.URI.resolve(URI.java:1043)", "org.neo4j.server.rest.batch.BatchOperations.calculateTargetUri(BatchOperations.java:100)", "org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:181)", "org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:159)", "org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:48)", "org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:117)", "org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:72)", "java.lang.reflect.Method.invoke(Method.java:601)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)"],
"cause": {
"message": "Illegal character in path at index 2: ./{0}/properties/Name",
"exception": "URISyntaxException",
"stacktrace": ["java.net.URI$Parser.fail(URI.java:2829)", "java.net.URI$Parser.checkChars(URI.java:3002)", "java.net.URI$Parser.parseHierarchical(URI.java:3086)", "java.net.URI$Parser.parse(URI.java:3044)", "java.net.URI.<init>(URI.java:595)", "java.net.URI.create(URI.java:857)", "java.net.URI.resolve(URI.java:1043)", "org.neo4j.server.rest.batch.BatchOperations.calculateTargetUri(BatchOperations.java:100)", "org.neo4j.server.rest.batch.BatchOperations.performRequest(BatchOperations.java:181)", "org.neo4j.server.rest.batch.BatchOperations.parseAndPerform(BatchOperations.java:159)", "org.neo4j.server.rest.batch.NonStreamingBatchOperations.performBatchJobs(NonStreamingBatchOperations.java:48)", "org.neo4j.server.rest.web.BatchOperationService.batchProcess(BatchOperationService.java:117)", "org.neo4j.server.rest.web.BatchOperationService.performBatchOperations(BatchOperationService.java:72)", "java.lang.reflect.Method.invoke(Method.java:601)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)"],
"fullname": "java.net.URISyntaxException"
}
}
What's the problem here?
No errors in messages.log or any other logs for that matter. Not sure why the logs are empty. I had to turn off the X-Stream header to get this much info.
Now I know that since I already know the node's ID I can just reference it directly, and I will. However, it seems like it is an issue that should work.
I guess the URL for the 2nd request should be
/node/{0}/properties/foo
OK so, I'm using RestClient and sending this:
{"x_select_params":["account.*"],"domain":"thedomain"}
Via
response = RestClient.get servername, #payload
And I get
undefined method `delete_if' for #<String:0x4b699a8>
In response.
I know that the request is good as it works fine when I use the Chrome rest client extension, I'm thinking that RestClient is having an issue in parsing the response, which is supposed to look like this:
{
"user": {
"id": 4035,
"first_name": "Chris",
"last_name": "Penta",
"status": "PENDING",
"domain": "thedomain",
"default_account_id": 111315004004010,
"primary_alias_id": 131090,
"accounts": [
{
"id": 111315004004010,
"urn": "111315004004010",
"balance": 0,
"status": 0,
"currency_code": 840
}
]
}
}
Is this a bug in RestClient that needs patching? And if so, anyone know how to fix?
Thanks...Chris
I found this error when the headers were in a json format. They needed to be a hash to work.