I'm tiring to create a new user in Moodle using auth_email_signup_user but I'm not sure how to format the request [closed] - api

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a few required custom profile fields that are date pickers and checkboxes. and I'm not sure what type to put them as in the request the only example the documentation has is one with type string. I keep getting the response
{
"exception": "invalid_parameter_exception",
"errorcode": "invalidparameter",
"message": "Invalid parameter value detected",
"debuginfo": ""
}
this is my request below:
https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=fromapp&password=FakePass123&firstname=From&lastname=App&email=fake#mailinator.com&customprofilefields[0][type]=text&customprofilefields[0][name]=profile_field_Church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=date&customprofilefields[1][name]=profile_field_DOB&customprofilefields[1][value]=2014-06-19&customprofilefields[2][type]=checkbox&customprofilefields[2][name]=profile_field_Saved&customprofilefields[2][value]=1&customprofilefields[3][type]=text&customprofilefields[3][name]=profile_field_Sex&customprofilefields[3][value]=Male&customprofilefields[4][type]=text&customprofilefields[4][name]=profile_field_phone_no&customprofilefields[4][value]=1-868-479-8661&customprofilefields[5][type]=text&customprofilefields[5][name]=profile_field_Marital&customprofilefields[5][value]=Single
I'm not sure what I need to do to make this request work and the documentation doesn't give much insight or I just haven't found it

So after playing around with the request on postman what I discovered is that the only type you need to use is string. I also discovered that for date fields the value must be unixtime and for checkboxes the value must be either 0 or 1.
https://example.com/webservice/rest/server.php?wstoken=faketoken&wsfunction=auth_email_signup_user&moodlewsrestformat=json&username=formapp7&password=fakepassword&firstname=From7&lastname=App7&email=fake#mailinator.com&customprofilefields[0][type]=string&customprofilefields[0][name]=profile_field_church&customprofilefields[0][value]=JesusYouth&customprofilefields[1][type]=string&customprofilefields[1][name]=profile_field_saved&customprofilefields[1][value]=Yes&customprofilefields[2][type]=string&customprofilefields[2][name]=profile_field_man&customprofilefields[2][value]=0&customprofilefields[3][type]=string&customprofilefields[3][name]=profile_field_born&customprofilefields[3][value]=1630813061&customprofilefields[4][type]=string&customprofilefields[4][name]=profile_field_single&customprofilefields[4][value]=Single&customprofilefields[5][type]=string&customprofilefields[5][name]=profile_field_aboutyou&customprofilefields[5][value]=Well i am new
This is an example of how a request would look where profile_field_man is a checkbox and profile_field_born is a date field. something also worth noting is that 'born' is the short name of the profile field mentioned before and the words 'profile_field_' must be prepended to it. I hope this helps anyone trying to use auth_email_signup_user

Related

Karate- Getting current date and manipulating it is not returning anything [duplicate]

This question already has an answer here:
Karate: Validate a specific date in JSON response
(1 answer)
Closed 1 year ago.
I apologize in advance if this seems like it's in the wrong place. However, what I have seems to work in pure JavaScript. However, when added in my Karate script, it's returning an empty object.
I have the following script:
* def currentDateMinusOne = new Date(new Date().setFullYear(new Date().getFullYear() - 1))
* karate.log("current date minus one year:", currentDateMinusOne)
The Karate log spits out an empty {}. Any ideas on what could be going on?
I don't know if the JavaScript Date behaves properly using the Karate JS engine, and I personally have never used it. You are welcome to experiment and report your findings.
My recommendation is to use Java interop. This example should get you going: https://stackoverflow.com/a/60945563/143475

Acumatica - Filter Generic Inquiry via REST

Trying to use this Generic Inquiry's REST API, I am able to retrieve all records though would like to filter them.
Can retrieve all data with PUT {{baseUrl}}/RawDataForReport?$expand=Result with an empty body request.
When I added a field Period to filter it's only showing the first row.
An empty request body also shows the first row when I added Period.
I am not at all familiar Acumatica any useful resources would be greatly appreciated.
To filter the Generic Inquiry result with REST API you need to add the filtering parameter to the GI itself. For instancce, you have your period filter defined in the Generic Inquiry. You can define more filters the same way.
You can learn about designing GIs here: https://openuni.acumatica.com/courses/reporting/s130-inquiries-reports-and-dashboards/
Another option would be to use OData instead of REST API. in that case you would be able to use $filter parameter to filter data.
You can read more about it here:
https://help-2020r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=36beb9aa-f04d-4f63-a93b-a00b1c315be0
https://help-2020r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=5d97a93d-45e0-466e-ba5e-77e1ccf96643
I've been struggling to find a solution to the same problem.
I just figured it out with the help of this stack overflow post.
Acumatica run Generic Inquiry via REST API
Take a look at the last response (not the accepted answer).
Basically when you define your object in the Web Service Endpoint screen, you can define the filters (Use Populate -> Filters). these are the Parameters for the GI.
You define the results the same as you have it.
Then in your PUT request body pass the parameters.
Example:
{
"Param1": {
"Value": "Value1"
},
"Param2": {
"Value": "Value2"
}
I just tested this with Postman, and it works well.

Using datepicker in DotNetNuke-7 module

I'm a DNN beginner. I am currently building a module in which I can display statistics. My DotNetNuke Version is 7.0. The statistic is from Chartjs. For this statistic I would like to implement filters. These filters should be datepickers. As UI element I have now included a textbox with TextMode='Date'. But currently I have problems to set the default value of this field. The default value should be 01.01. of the current year.
I have already tried to set the value via C# server side. Unfortunately without success. I also tried to set the value on the client side via JavaScript. Unfortunately also without success.
These are some lines I tried in JavaScript:
document.getElementById(<%= this.DatumVon.AccessKey %>).value = "01.01.2019";
document.getElementById(<%= this.DatumVon.AccessKey %>).innerText = "01.01.2019";
document.getElementById("DatumVon").value = "01.01.2019";
These are some lines I tried in C# in the method "Page_Load" (server side):
this.DatumVon.Text = "01.01.2019";
I expected the value of the TextBox to be 01.01.2019. However, it currently only contains dd.mmm.yyyy. How can I change this?
Thank you.
There is something wrong with your localization. Please refer to the jQuery UI datepicker documentation (the "Localization" section), this should give you the answer.
wow... I solved it. I made it. Sometimes the solution is right in front of you and you don't see it. Michael Tobisch was absolutely right. When setting the value, the format is very important. I have always used the German format. A DNN TextBox with TextMode="Date" can't handle that. DNN converts this TextBox into an HTML input field. But this input field can only be clear with the format "yyyy-mm-dd". Depending on the geographical position of the client (at least that's what I think) the text displayed in the input field will be formatted. But the value of the input field always has the same format ("yyyy-mm-dd"). So very important here: the displayed text and the actual value have different formats.
Many thanks again to Michael Tobisch for the mental inspiration and the patience with me.
What is also important is that the access to the actual ID of a DNN element works as follows: this.Element.ClientID and not as I assumed before this.Element.AccessKey. This was also buggy.

Karate Automation: Is there any way we can set the Scenario name dynamically from a json file [duplicate]

This question already has answers here:
Can we parameterize the request file name to the Read method in Karate?
(2 answers)
Closed 1 year ago.
I am using a JSON file which act as a test case document for my API testing. The JSON contain Test Case ID, Test case Description, Header and Request body details, which should be the driving factor of Automation
Currently i am looping a feature over this json file to set different header and body validations. However it will be helpful if i can set the Scenario name from JSON file while its iterating
Something like
serverpost.feature
Feature:re-usable feature to publish data
Scenario: TC_NAME # TC_NAME is avaliable in the JSON data passed to this feature. However, CURRENTLY ITS NOT TAKING THIS DATA FROM JSON FILE.
Given path TC_ID # TC ID is taken from JSON
Given url 'http://myappurl.com:8080/mytestapp/Servers/Data/uploadServer/'
And request { some: '#(BODY)' } # Request Body Details is taken from JSON
Please suggest
In my honest opinion, you are asking for a very un-necessary feature. Please refer to the demo examples, look for it in the documentation.
Specifically, look at this one: dynamic-params.feature. There are multiple ways to create / use a data table. Instead of trying to maintain 2 files - think of Karate as being both - your data table AND the test execution. There is no need to complicate things further.
If you really really want to re-use some JSON lying around, it is up to you but you won't be able to update the scenario name, sorry. What I suggest is just use the print statement to dump the name to the log and it will appear in the HTML report (refer to the doc). Note that when calling a feature in a loop using a JSON array, the call argument is ALREADY included the report, so you may not need to do anything.
Just an observation - your questions seem to be very basic, do you mind reading the doc and the examples a bit more thoroughly, thanks.

Google Rest api to get primary mail [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to get the gmail primary mail using Google rest API.Currently i am using the GET https://www.googleapis.com/gmail/v1/users/userId/messages Rest API but that will give the social and promotion mail.I am referring this site:https://developers.google.com/gmail/api/v1/reference/users/messages/list
Try adding this as a filter in your query when calling messages.list
[ in:inbox -category:{social promotions updates forums} ]
that only gives you the good stuff. It's basically saying give me everything in the inbox apart from social, promotions, updates and forums.
Or in my inbox I also seem to have updates so you'd change to
[ in:inbox -category:{social promotions forums} ]
Cheers
John
Its pretty straight forward actually
We can query the messages by using labels. Labels are of two types System labels and User Labels.
For primary we can use System label called "INBOX" and get the emails that belong to that category. There are other system labels like CATEGORY_PROMOTIONS, CATEGORY_SOCIAL etc.
You can use the Try It! feature with Google to test it out.
Get labels:
https://developers.google.com/gmail/api/v1/reference/users/labels/list
For a given label, say INBOX in your case query the messages
https://developers.google.com/gmail/api/v1/reference/users/messages/list
You can also get the STARRED, CATEGORY_PERSONAL for starred and important emails from the inbox.
Edited for sample code.
Java Code Sample available within the link, but a snippet here:
public static void listLabels(Gmail service, String userId) throws IOException {
ListLabelsResponse response = service.users().labels().list(userId).execute();
List<Label> labels = response.getLabels();
for (Label label : labels) {
System.out.println(label.toPrettyString());
}
}