I am currently using IBM API Connect as my application for creating my API. I have an input parameter that I would like to set the maxLength for, and have it so the API is throwing an error if the input for the parameter is larger than the maxLength defined. Currently I have the code below, and the API is still allowing for much larger strings than 10. I was just curious is I for one am defining the maxLength for the input parameter correctly, and two, if the IBM API Connect framework just doesn't provide the ability to set a max length for an input parameter.
parameters:
- name: test2
type: string
maxLength: 10
minimum: 1
maximum: 10
required: false
in: query
description: test2
Related
We are migrating from Mule 3 to Mule 4 and in one of our functionalities we need to publish messages to a topic and downstream another mule component is consuming from the queue which is bridged to the topic.
Nothing special here .
To ensure we are able to trace the flow via logs we were sending a 'TrackingId' attribute while publishing messages to the topic ( Mule 3 )
message.setOutboundProperty("XYZ_TrackingID", flowVars['idFromUI']);
return payload;
However when I try the same in Mule 4 we get the following exception :
ERROR 2020-12-20 10:09:12,214 [[MuleRuntime].cpuIntensive.14: [mycomponent].my_Flow.CPU_INTENSIVE
#66024695] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
Message : groovy.lang.MissingMethodException: No signature of method:
org.mule.runtime.api.el.BindingContextUtils$MessageWrapper.setOutboundProperty() is applicable for
argument types: (java.lang.String, org.mule.weave.v2.el.ByteArrayBasedCursorStream) values:
[XYZ_TrackingID, "1234567"].\nError type : (set debug level logging or '-
Dmule.verbose.exceptions=true' for
everything)\n********************************************************************************
Checked internet and it seems in Mule4 setting outbound properties is removed as per here
So how do I achieve the same in Mule 4 ?
Don't even try to do that for several reasons. For one message structure is different, so output properties doesn't exist anymore and that method doesn't even exists. On the other hand, in Mule 4 components like the Groovy component can only return a value and cannot change the event. They can not decide to what that value is going to be assigned. You can set the target in the configuration (payload or a variable) and not change the attributes. Note that variables in Mule 4 are referenced by var., not by flowVars. like in Mule 3 (ie vars.idFromUI).
There is a simpler way to set message properties in the Mule 4 JMS connector. Use the properties element and pass it an object with the properties.
For example it could be something like this:
<jms:publish config-ref="JMS_config" destination="${bridgeDestination}" destinationType="TOPIC">
<jms:message>
<jms:body>#["bridged_" ++ payload]</jms:body>
<jms:properties>#[{
XYZ_TrackingID: vars.idFromUI
}]</jms:properties>
</jms:message>
</jms:publish>
It is in the documentation: https://docs.mulesoft.com/jms-connector/1.0/jms-publish#setting-user-properties. I adapted my example from there.
I am not sure if Correlation Id serves the purpose of a tracking ID for your scenario. But you can pass a CID as below. It's there in the mule documentation.
https://docs.mulesoft.com/jms-connector/1.7/jms-publish
<jms:publish config-ref="JMS_config" sendCorrelationId="ALWAYS" destination="#[attributes.headers.replyTo.destination]">
<jms:message correlationId="#[attributes.headers.correlationId]"/>
</jms:publish>
If your priority is to customise the Tracking ID you want to publish, then try passing below format. The key names may differ as per your use case.
<jms:publish config-ref="JMS_config" destination="${bridgeDestination}" destinationType="TOPIC">
<jms:message>
<jms:body>#["bridged_" ++ payload]</jms:body>
<jms:properties>#[{
AUTH_TYPE: 'jwt',
AUTH_TOKEN: attributes.queryParams.token
}]</jms:properties>
</jms:message>
</jms:publish>
In the above the expression attributes.queryParams.token is basically trying to access a token query parameters which is passed to JMS as a property AUTH_TOKEN key-name , consumed by the API through a HTTP Listener or Requestor earlier.
However, attributes.headers.correlationId is a header. Both queryParams and headers are part of attributes in Mule 4.
I have created a small identity network using Insomnia workspace as it described here https://developer.oftrust.net/guides/workflow-using-insomnia-workspace/ I have account on sandbox.
I wanted to validate the identity graph was created as defined so I tried some requests from Identity API. As described in docs here. Tried https://api-sandbox.oftrust.net/identities/v1/discovery with query parameters values:
fromId : <building_identity_id>
linkContext: https://standards.oftrust.net/v2/Context/Link/BelongsTo/
identityContext: https://standards.oftrust.net/v2/Context/Identity/Equipment/Device/
linkDirection : IN
maxDepth : 5
offset: 0
limit : 100
and got in response identities object with some identities.
Then I tried https://api-sandbox.oftrust.net/identities/v1/dataDiscovery with query parameters values:
fromId : <building_identity_id>
linkContext: https://standards.oftrust.net/v2/Context/Link/BelongsTo/
identityContext: https://standards.oftrust.net/v2/Context/Identity/Equipment/Device/Sensor/TemperatureSensor/
linkDirection : IN
maxDepth : 5
offset: 0
limit : 100
and got response with "dataProducts": {}
What is wrong in above https://api-sandbox.oftrust.net/identities/v1/dataDiscovery request?
I see https://standards.oftrust.net/v2/Context/Identity/Equipment/Device/Sensor/TemperatureSensor/ is defined and it was used as context in Insomnia workspace setup of identity network.
You need to use another query parameter, basically which discovers the AtDataProduct type of Link ( which has been created between Sensors and Data products)
atDataProductContext : https://standards-ontotest.oftrust.net/v2/Context/Link/AtDataProduct/
See this note from guide:
A special link type is AtDataProduct. In an identity network, a sensor identity MUST be connected to a Data Product with a link type AtDataProduct. The direction MUST BE "from sensor to Data Product". This is important to consume harmonized data flow in an identity network.
In a nutshell, part of the identity network should be something similar to this:
Temperature Data Product <--AtDataProduct-- Temperature Sensor --BelongsTo--> Room
I'm building an API that's able to upload multiple files at once. I need to document it through swagger, but I have no experience with it at all.
My schema for the API is as follows:
The http request body is an octet-stream that looks like this. The first 4 bytes represents the number of packages, let the number of packages be n. The next 4*n bytes represents the sizes of the packages, where the first 4 bytes is the size of the first package, the next 4 is the size of the second package, etc. The end of the request simply consists of the packages.
An example would be: The packages \xDE\xAD\xBE\xEF and \xFE\xED\xFA\xCE\xCA\xFE\xBE\xEF, would compose the request:
\x00\x00\x00\x02||\x00\x00\x00\x04\x00\x00\x00\x08||\xDE\xAD\xBE\xEF\xFE\xED\xFA\xCE\xCA\xFE\xBE\xEF
I've tried documenting this in swagger like this:
Batch:
type: object
properties:
header:
description: The number of packages represented in binary (big endian).
type: string
format: binary
maxLength: 8
minLength: 8
example: \x00\x00\x00\x02
subheader:
description: The size of each package, where the size of the first package is represented by the first 4 bytes, the second by the next 4 bytes, etc (big endnian).
type: string
format: binary
maxLength: 4294967295
minLength: 0
example: \x00\x00\x00\x04\x00\x00\x00\x04
data:
description: The data block for encryption/decryption
type: string
format: binary
maxLength: 18446744073709551616
minLength: 0
example: \xDE\xAD\xBE\xEF\xDE\xAD\xBE\xEF
But it shows the request body as a json object (due to type: object).
Any ideas on how to do this properly?
Octet-stream request body is defined as a single binary string. There's no way to define the contents/format of specific fragments of the octet-stream. minLength and maxLength can be used to limit the size of the entire stream.
Also note that this is OpenAPI 3.0. OpenAPI 2.0 does not support application/octet-stream payloads (it only supports multipart/form-data).
openapi: 3.0.2
paths:
/something:
post:
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
maxLength: 12345
I'm having some difficulties implementing the MFA workflow with Yodlee. The workflow does not specify how to proceed with multi-level banks, for example, when a bank asks for a phone number to send an SMS with a temporary PIN.
{
isMessageAvailable: true
fieldInfo: {
responseFieldType: "text"
minimumLength: -1
maximumLength: 25
displayString: "Enter your Mobile Number or eMail ID where to send the temporary PIN"
} -
timeOutTime: 111750
itemId: 0
memSiteAccId: xxxxxxxx
retry: false
}
In this situation, what do I have to do? Keep calling the getMFAResponseForSite every 2 seconds?
Also, in order to perform the putMFARequestForSite, which type should I use?
com.yodlee.core.mfarefresh.MFATokenResponse
com.yodlee.core.mfarefresh.MFAQuesAnsResponse
com.yodlee.core.mfarefresh.MFAImageResponse
As there are 3 types of MFA (to know about types of MFA refer what-is-the-mfa-differences-spotted-in-this-case
To differentiate you can use the response of getMFAResponseForSite.
SECURITY_QUESTION - The response from getMFAResponseForSite looks like -
fieldInfo":{
"questionAndAnswerValues":[
{
hence you need to use com.yodlee.core.mfarefresh.MFAQuesAnsResponse
IMAGE - The response from getMFAResponseForSite looks like -
fieldInfo":{ "responseFieldType":"text",
"imageFieldType":"image",
"image":[
hence you need to use com.yodlee.core.mfarefresh.MFAImageResponse
TOKEN_ID - The response from getMFAResponseForSite looks like -
fieldInfo":{ "responseFieldType":"text"
Since there will not be any indication of Q&A or Image hence you need to use com.yodlee.core.mfarefresh.MFATokenResponse
You can also check the various responses of MFA at getMFAResponseForSite and getMFAResponse. The fieldInfo returned in both the methods will be same and hence can be used to identify the type of MFA.
Hence in case of multilevel MFA you will have to use any combination of the 3 listed MFA types.
I'm trying to create a very basic query in the Defect app (Submitted by = my Name) however when I save, the following message is returned:
Could not parse: Unknown operator "By"
You should use camel case instead of spaces in fields names when using the Rally Web Services API (WSAPI), so in this case the field should be called SubmittedBy.
You can see all the available fields on Defect here in the documentation:
https://rally1.rallydev.com/slm/doc/webservice/objectModel.sp#Defect