REST API error while posting a customized Priority fields - priority-web-sdk

I'm trying to post REST API of the ORDERS form.
I have added a few customized fields to the sub form PAYMENTDEF in order to post all the credit cards information.
I'm getting the error:
'An error has occurred'
any time I'm posting the customized fields, if I remove them from the request I managed to post.
{"CUSTNAME":"5","CDES":"רועי בן מנחם","CURDATE":"2018-07-18","BOOKNUM":"2164","SHIPTO2_SUBFORM":{"NAME":"רועי בן מנחם","PHONENUM":"0507573753","ADDRESS":"דן 4","STATE":"שערי תקווה","COUNTRYNAME":"Israel","ZIP":"44810","ADDRESS2":"44"},"ORDERITEMS_SUBFORM":[{"PARTNAME":"CLEAN0044","TQUANT":1,"PRICE":19.9,"REMARK1":"","ROYY_ORDISPECS_SUBFORM":[]},{"PARTNAME":"000","TQUANT":1,"PRICE":30,"REMARK1":""}],"PAYMENTDEF_SUBFORM":{"PAYMENTCODE":"3","QPRICE":53.28,"PAYACCOUNT":"1234","PAYCODE":"","VALIDMONTH":"0124","CCUID":"123456789","CONFNUM":"09090909","ROYY_NUMBEROFPAY":"","FIRSTPAY":"","ROYY_SECONDPAYMENT":""}}
And this is my header:
https://pri.officeandmore.co.il/odata/Priority/tabula.ini/tirgul2/ORDERS

Try check if these fields are visible in the REST api service:
Request the service metadata as following:
https://pri.officeandmore.co.il/odata/Priority/tabula.ini/tirgul2/$metadata
In the result check for the PAYMENTDEF subform's metadata (search for <EntityType Name="PAYMENTDEF"> and check if your customized fields appear in the property (field) list.
If they don't appear, probably these fields are set as 'hidden fields' in the 'Priority form' or that you have permission limitations.
If they do appear, the problem is probably related to incorrect values you are trying to post to these fields. Take a look in the metadata result to see the expected values format for each of these fields.

Related

jira createmeta not showing all customfields

If I navigate to /rest/api/2/issue/createmeta/PROJ/issuetype/N (in this case, I'm getting Task), the list of fields returned is incomplete. There are a number of customfields that are in use (I can see them both in the tickets themselves, and also in /plugins/servlet/project-config/PROJ/fields ) that are in the createmeta data.
I'm really trying to do this in python jira, where I'm using "expand='projects.issuetypes.fields'" in the createmeta() call, but I figured I'd double-check the results in the rest API directly, and I'm getting the same results there, too.
This is happening in jira 8.20.7.
Essentially, what I'm trying to do, is to programatically get a name/id mapping of all fields in the ticket type. I'm having far more difficulty doing that than I thought there would be. I would do it based on /rest/api/2/field but the jira admins have allowed some duplicated names...
EDIT: I realized that it might be worth noting that some of the fields I'm looking for are coming from a ServiceDesk form, although, as far as I can tell, there's no way to determine that, since one of the missing fields contains the name of the form.
Why are you using createmeta endpoint?
Instead of that, in order to get all of the customfields and their values; just note their id and get the values from /rest/api/2/issue/{issueKey} endpoint.
When you send a GET request to /rest/api/2/issue/{issueKey} endpoint, you will get a JSON object which contains "fields" object in it.
And using the "fields" you can determine all of the values that include system fields (description, assignee, etc.) and custom fields (like customfield_<customfieldid>).
And for a general approach, you may want to look at the field types in that response.

Select fields on Microsoft Graph list of Messages

I'm using Microsoft Graph to get a list of messages for a user.
I'm using the following URL
https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages
One important thing that is returned by this is the meetingMessageType when the message revolves around a meeting request.
I would also like to get the uniqueBody of the message. However, that's not provided by default. One needs to specifically ask for that field. I can do that by adding ?$select=uniqueBody to the URL.
However, that now means that I need to add the rest of the fields I want to the $select query parameter. That's not a big deal until I run into meetingMessageType. Microsoft Graph returns:
Could not find a property named 'meetingMessageType' on type 'Microsoft.OutlookServices.Message'.
What can I do to ensure I get both uniqueBody and meetingMessageType?
Try this:
$select=uniqueBody, microsoft.graph.eventMessage/meetingMessageType
Yogesh's answer is close but will result in a Only one level select is supported error.
As long as you don't care about the value of meetingMessageType, you can use this select:
$select=microsoft.graph.eventMessage, uniqueBody
You'll note that the results no longer include meetingMessageType as a property. The list however is limited to only those messages that are eventMessage, effectively giving you a result set filtered to only show meeting requests.

How can I get list of all data set codes of Quandl API?

I want list of all dataset codes for each company,Ex. for Facebook dataset code is FB,for MICROSOFT it is MSFT.How can I get such list of all available codes for data sets ??
You can get the list of all the available datasets in a database provided you have the database name.
GET https://www.quandl.com/api/v3/datasets?database_code=<database-name>&api_key=<api-key>
Replace the value <database-name> and <api-key> in the above URL. This will return a list of dataset object. Each object will have a dataset_code field having the required value.
Make sure you register on the quandl website for getting the access key. You do not have to pay or give credit card details for registration.
For JSON response you can use the below. Also you can mention the current page and page size as below -
https://www.quandl.com/api/v3/datasets.json?database_code=${databaseCode}&api_key=${apiKey}&current_page=${currentPage}&per_page=${perPage}

How to return custom error codes in a Rails API?

Given a RESTful API, implemented in Rails, I want to include in the responses not only the errors messages, generated by ActiveModel::Validations, but also custom error codes. First of all I would like to point out that I am not talking about HTTP Status codes. I am talking about having an error of any type (from general errors like record not found to small validation errors like username can't be blank) be mapped to a unique numeric code, that is custom application-specific error codes. Let me give an example - given a list of error codes, like:
1: record not found
... some other errors
# Validation errors for User model between 1000 to 2000
1001: first name can't be blank
1002: first name must contain at least 3 characters
1003: last name can't be blank
1004: last name must contain at least 3 characters
...some other errors
If I have a form for a user and submit it with empty fields for first and last name, I want to have in the response body something like:
{error_codes: [1001, 1002, 1003, 1004]}
or something similar (for example I could have an array of error objects, each with a code, message for developer, message for user etc.). Let me give an example with the Twilio API, taken from RESTful API Design: what about errors?:
Here, 20003 is some custom Twilio-specific code. The question is - how can this be implemented in Rails? I see several difficult aspects:
how do I get a list of all possible errors that can be encountered. It is hard to get such a list even only for the validation errors, let alone the other types of errors that can occur.
how should this list be organized - maybe in a YAML file?
how do I access the list - maybe something similar to the way translations are accessed via I18n.t?
I will really appreciate any advice on the topic. Thank you.
P.S. I think this is a similar question.
ActiveModel built-in validators can be found here. Sometimes one validator can check for more than one thing and output different messages. The easiest way to see them all is, as you've guessed, in its I18n yaml file, which can be found here.
One way of doing what you want is overwriting those messages with your custom codes. Another way is passing a custom message when explicitly attaching a validator to your models.
validates :name, message: 'code:001 - my custom message'
Those two options won't help you with structure, though. You won't have a different key code on your json out of the box.
One way you can accomplish that is to can create a helper to parse the error messages and extract the codes after they have been assigned to a model instance. Something along the lines of:
def extract_error_codes(error_messages)
error_messages.map{ |message| message.match('^code:(\d+)\s-')[1] }
end
That would give you an array of error codes for that instance if you'd used the format code:001 - my custom message.
Another, much more involved way, is to tap into ActiveModel's Validator class and store an error code when a validation fails. That would require going into each validator to assign the code.

Is there any way to keep validate field optional in rails?

I have User model which includes 7 fields. for all these fields validation is written.i have two form where i am displaying fields depend on condition. in one form i have name password and city and other form i have role,phone and name.
When i try to submit the first form i got the error which says phone and role field are required resulting into failure of form.
Is there any way by which i can submit both form without getting the validation errors ??
Note : i want my logic to be in model only.. Please help me with this problem.
You could use a conditional validation to achieve what you want:
See here: http://guides.rubyonrails.org/active_record_validations.html#conditional-validation
However, this can quickly get hard to manage. Depending on the condition you're switching on, it'd probably be a cleaner design to use a 'Form Object' which will give you more control and let you do validations without the messy conditional logic.
See section #3 of this blog post for more detail:
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
Using this pattern, you would check for your condition in the controller then determine which form object to send to the view.

Resources