Hello there
I'm having a trouble when I try to insert a document into a Ravendb Server which is running in my other computer. I can retrieve documents easily, but when I try to use REST API with POST request I get this error
"System.ArgumentException","Message":"Query string value 'id' must have a non empty value","Error":"System.ArgumentException: Query string value 'id' must have a non empty value
even though I have my Id defined like this:
{
"id":"adawd",
"name":"genereicname",
"password":"something"
}
Originally I'm making a flutter application but currently I'm just testing the API with Postman.
I messed around with id's (String, int) tried to leave it empty but no luck, does anyone know how to define Id for raven db to send me that sweet 200 response code...
According to the documentation you should use PUT to upload a new document or modify an existing one.
See: https://ravendb.net/docs/article-page/5.2/csharp/client-api/rest-api/document-commands/put-documents
Related
I'm using JPA with CosmosDB to fetch entries from containers.
I have to implement pagination and, according to the documentation, it should rely on the requestContinuation string, which is null on the first request and not null afterwards.
To make things more simple, I created a basic app which calls the repository, takes the requestContinuation object and then makes a new request using it's value.
I have 8 objects in the CosmosDB container and the page size is 5. The first request returns 5 elements and the requestionContinuation value
{"compositeToken":"{\"token\":null,\"range\":{\"min\":\"\",\"max\":\"FF\"}}","orderByItems":[{"propertyBag":{"item":[2021,5,20,14,13,52,716826900]},"item":[2021,5,20,14,13,52,716826900],"map":{"item":[2021,5,20,14,13,52,716826900]}}],"rid":"7eYNAKj8mAMIAAAAAAAAAA==","inclusive":true}
I use it, AS IT IS, to make a new request
Pageable pageable = new CosmosPageRequest(0, size, requestContinuation, Sort.by(sort));
return repo.findAllByUserId(userId, pageable);
The result is empty and the new requestContinuation is null. The page object correctly states that the total number is 8 but never returns the missing 3.
The value of the requestContinuation is not a valid JSON, if you analyze it. I also tried replacing the \ from the compositeToken part of the JSON, which made it a valid JSON. If the invalid JSON is accepted by CosmosDB but the result is empty, the valid JSON is rejected as being INVALID :)
I looked into various sources and I saw something about encoding. I tried to URLEncoder class but it didn't work.
Does anybody have an idea?
Thanks.
UPDATE
The query is also sorting by the creation date. If sorting is removed, the new token works. It's structure is different.
Old token - with sorting:
{"compositeToken":"{\"token\":null,\"range\":{\"min\":\"\",\"max\":\"FF\"}}","orderByItems":[{"propertyBag":{"item":[2021,5,20,14,13,52,716826900]},"item":[2021,5,20,14,13,52,716826900],"map":{"item":[2021,5,20,14,13,52,716826900]}}],"rid":"7eYNAKj8mAMIAAAAAAAAAA==","inclusive":true}
New token - no sorting:
{"token":"+RID:~7eYNAKj8mAMKAAAAAAAAAA==#RT:1#TRC:5#ISV:2#IEO:65567#QCF:4#FPC:AQoAAAAAAAAADQAAAAAAAAA=","range":{"min":"","max":"FF"}}
The second request, with the continuationToken, was returning an empty response because the ordering field was a LocalDateTime field, which in CosmosDB is serialized as an array. I fixed the issue by adding this to the LocalDateTime field:
#JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss'Z'")
This way, the sorting field is a string and can be used for ordering.
Just Encode the Request Token and it will work like charm
I'm trying to set up a webpage that communicates with a Moodle page. I need different data from a database activity and want to create new entries. Note that I am not talking about the SQL database in BG, it is the activity database in courses.
The information should be retrieved/transferred via the REST API, an HTML POST Request. My problem is that I don't know how to add a new record to the database activity because I cannot transfer the data array. Only the first parameter given appears in my database.
E.g. i tried ...&wsfunction=mod_data_add_entry&databaseid=10&data[0][fieldid]=66&data[0][value]=12&data[1][fieldid]=67&data[1][value]=test
And many other combinations. Always only the first parameter is shown in the database.
The docs tell me this (Pseudocode):
//The fields data to be created
list of (
object {
fieldid int //The field id.
subfield string Default to "" //The subfield name (if required).
value string //The contents for the field always JSON encoded.
}
)
Alternatively:
REST (POST parameters)
data[0][fieldid]= int
data[0][subfield]= string
data[0][value]= string
I cannot find anywhere else something called a "subfield".
Any ideas?
Okay, found it. You have to put your values in "", unless they are not a number. Seems like there is a connection with this special activity because you don't have to do it elsewhere.
Anyone been able to successfully update the custom_field_values for a matter via Clio's API?
I'm trying to update the value for custom_field_values under a single matter. I'm able to send a JSON string using PATCH and update the default values for a matter like location or description using the following format
{"data":{"location":"Orange"}}
But when it comes to updating a "custom field value" I'm getting a 422 Unprocessable Entity error. I'm following Clio's v4 API Documentation and my understanding is that to update a custom_field_value you need the following JSON:
{"data":{"custom_field_values":[{"id":658213,"custom_field":{"id":139385},"value":"New Value Goes Here!"}]}}
However here is the message coming with the 422 error:
{"error":{"type":"ArgumentError","message":"An invalid argument was supplied: invalid custom field value id provided, acceptable format is <type>-<unique id>"}}
I can't interpret the part suggesting the acceptable format!
I've also tried sending the JSON in the following format which is closest to Clio's V2 API Docs for updating a custom field:
{"data":{"custom_field_values":[{"custom_field":{"id":139385},"value":"New value goes here"}]}}
But then this is what I get back:
{"error":{"type":"ArgumentError","message":"An invalid argument was supplied: custom field value for custom field 139385 already exists"}}
Please note that this is being tested in POSTMAN regardless of my development environment. I appreciate your response!
I've successfully created queries to update custom field values in matters many times, and these run all the time for me. I've compared your json to some examples of the json I'm successfully sending. Your syntax appears correct, but there's enough missing for me to only guess at where your mistake might be.
First, you're sending a PATCH to https://app.clio.com/api/v4/matters/{matter id}.json right? It took me a while to learn that you can't update the value of a matter's custom field with a query to https://app.clio.com/api/v4/custom_fields/{id}.json.
Second, just to clarify, the 658213 id you used above (the first id field) should be the unique id of this instance of your custom field. You won't get this until you've created an instance of the custom field particular to this matter. The second id field, where you've put 139385 is the id for the custom field itself, which you could get with a query to https://app.clio.com/api/v4/custom_fields.json.
If you're looking in the V.4 docs under Custom Fields, you won't find this, or at least I didn't. BUT you can find it in the intro section to the Matters portion fo the documentation: https://app.clio.com/api/v4/documentation#tag/Matters
Hope this helps. I'd imagine someone at Clio could help by verifying your error string is delivered when you have an incorrect custom field value unique id.
To further clarify Jacob's answer for everyone else:
custom_field{id} is the id given to a custom_field when it's created and will be the same for all matters or contacts it's used in.
custom_field_value{id} is the id given to an instance of the custom_field added to a particular matter and unique only to that matter
To add a custom_field to a matter for the first time the following format is used:
{"data":{"custom_field_values":[{"custom_field":{"id":123456},"value":"string or integer depending on the type of CF"}]}}
To update a custom field already added to a matter the following format should be used:
{"data":{"custom_field_values":[{"id":"text_line-1234567", "custom_field":{"id":123456},"value":"string or integer depending on the type of CF"}]}}
To delete a custom field already added to a matter the following JSON format is sufficient:
{"data":{"custom_field_values":[{"id":"text_line-1234567", "custom_field":{"id":123456},"_destroy":true}]}}
Format for updating a custom field already added to a matter:
{"data":{"custom_field_values":[{"id":"unique_instance_of_your_custom_field", "custom_field":{"id":'custom_field_id'},"value":"value which should be updated"}]}}
Here, the first id field should be the unique id of this instance of your custom field. To get this value follow this documentation section, app.clio.com/api/v4/documentation#tag/Matters and the second id field is the id for the custom field itself.
Recently i migrated all my parse data to MongoLab. i'm saving documents (parse object) directly to mongoDb using MongoClient.save(...), and not using parse SDK.
now mongo generate auto id, in my case - '56eac5ea1ac8242012ae4ed9', and parse dashboard not show any row in this class till i delete this object (document) and i'm getting the next error: objectId must be a string: ObjectIdHex("56eac5ea1ac8242012ae4ed9")
should i save id differently?
how to convert my id to regular Parse object id? (if i reallty need it?)
any solution?
I know parse dashboard is temporary, but right now it helps
It occurs because by default Mongo create an ObjectId for each object stored in its collections. To overcome it, you have to order Mongo store your own generated Id.
You can do it by sending the _id property in your object that is being stored in Mongo. Something like this:
db.collection('_User').save({_id: yourid, ...})
You can generate any random string id, but it would be good to generate the _id as the same way Parse Server does. If you check Parse Server repository (https://github.com/ParsePlatform/parse-server/blob/master/src/cryptoUtils.js) you can find how the id is generated.
Anyway. There are solutions, like www.back4app.com, that already provides full hosting of both parse server, parse dashboard and database
--
Disclosure: I am founder of back4app.com
I have simple app which displays list of recrods, also user whould be able to edit barticular record by id.
Because list is big, i don't fetch it as whole, but partially via Product.fetch(data: $.param(page: 1)).
Then when someone try to edit record, i call Product.find(id) and if recrord was already prefetched with fetch then it works fine, but when record not yet fetched then i got error like: "Product" model could not find a record for the ID "1152"
So, the question is why find not performing ajax call and how to make it perform it or maybe there is another solution exists ?
Spine.find only looks in the already loaded records. Doing an ajax request isn't the function of find. So you have to try-catch your find and when it gives this error, you have to fetch it.
id = 1152
try
product = Product.find id
catch err
Product.fetch(
data:
id: id
processData: true
)
# Try again after Product.refresh
To be honest, I think this isn't a nice way to do it, but it is how spine works... I rather have it fetch it automatically, or at least not throwing an error on find.